This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NSObject+AssociatedObjects.m | |
// | |
// Created by Andy Matuschak on 8/27/09. | |
// Public domain | |
// | |
// edited by rebo to add message forwarding, so extended objects can call zero-argument void | |
// blocks using [instance method] format. | |
// | |
// Not really recommended as this produces "may not respond" warnings in compiler. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// setting up the binding for my table here, this works ok: | |
contentBinding: 'Training.operativesController.arrangedObjects', | |
selectionBinding: 'Training.operativesController.selection', | |
// then trying to access the selection in the console gets this: | |
Training.operativesController.selection.get('firstObject') | |
TypeError: Result of expression 'Training.operativesController.selection.get' [undefined] is not a function. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nameValue: SC.LabelView.design({ | |
layout: { | |
top: 30, | |
left: 125, | |
height: 24, | |
width: 200 | |
}, | |
valueBinding: "Training.operativesController.get('selection').get('firstObject').get('name')" | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var operatives = Training.store.find(Training.OPERATIVES_QUERY).toArray(); | |
console.log('Loading operatives'); | |
Training.operativesController.set('content', operatives); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Employee < ActiveRecord::Base | |
has_many :events | |
def self.in_on_date(date) | |
Event.where(:date => date).map{ |e| e.employee.name }.uniq | |
end | |
def book_in_date!(date) | |
self.events.build(:date => date) | |
self.save! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AttributeAccessor < Module | |
def initialize(name) | |
@name = name | |
@name_ivar = "@#{@name}" | |
end | |
def included(model) | |
super | |
define_accessors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Comparison of a dumb facade implementation to #extend. | |
# The principle advantage is that with caching it might be quicker that #extend, | |
# and it isolates the data_object so no behaviour | |
# changes persist after a context is finished. | |
# | |
require 'benchmark' | |
require 'singleton' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreatePartyAccountOrderSaga < Saga | |
attr_reader :saga_info | |
def initialize(saga_id, party_attributes, account_attributes, order_attributes) | |
@saga_id = saga_id; | |
start(party_attributes, account_attributes, order_attributes) | |
end | |
def start(party_attributes, account_attributes, order_attributes) | |
fiber_based_workflow do | |
party_id = saga_exec("Creating Party..."){CreateParty.execute(*party_attributes)} | |
raise CreatePartyFailedError, "Party Creation Failed" if timeout? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'alias_dci' | |
class Article < Struct.new(:subject,:body);end | |
class TextView | |
attr_reader :contents | |
def initialize | |
@contents = "" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'alias_dci' | |
class Battle | |
include AliasDCI::Context | |
role :lion do | |
def fight | |
p "#{name}: RAWR, I am a lion and I run fast." | |
end | |
end | |
OlderNewer