class Dicer::Context::Description
Attributes
behaviors[R]
described_class[R]
Public Class Methods
new(described_class, &block)
click to toggle source
# File lib/dicer/context/description.rb, line 6 def initialize(described_class, &block) @described_class = described_class @behaviors = {} @behaviors.default = [] @delegators = {} instance_eval(&block) if block_given? end
Public Instance Methods
delegator()
click to toggle source
# File lib/dicer/context/description.rb, line 39 def delegator @delegators.default ||= Dicer::Delegator.make( @described_class, @behaviors.default ) end
delegator_for(role)
click to toggle source
# File lib/dicer/context/description.rb, line 46 def delegator_for(role) role = role.to_s.to_sym if @delegators.has_key?(role) @delegators[role] else @delegators[role] = Dicer::Delegator.make( @described_class, @behaviors[role] ) end end
it_behaves_like(behavior)
click to toggle source
# File lib/dicer/context/description.rb, line 16 def it_behaves_like(behavior) @behaviors[@role] << behavior end
merge!(other)
click to toggle source
# File lib/dicer/context/description.rb, line 27 def merge!(other) other.behaviors.each_pair do |role, behaviors| if @behaviors.has_key?(role) @behaviors[role] = @behaviors[role] | behaviors else @behaviors[role] = behaviors end end @behaviors.default = @behaviors.default | other.behaviors.default end
role(name, &block)
click to toggle source
# File lib/dicer/context/description.rb, line 20 def role(name, &block) @role = name.to_s.to_sym @behaviors[@role] = [] unless @behaviors.has_key?(@role) instance_eval(&block) if block_given? @role = nil end