Class: ActionFactory::Assignments::Trait

Inherits:
Object
  • Object
show all
Defined in:
lib/action_factory/assignments/trait.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block) ⇒ Trait

Returns a new instance of Trait.



8
9
10
# File 'lib/action_factory/assignments/trait.rb', line 8

def initialize(block)
  @block = block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



6
7
8
# File 'lib/action_factory/assignments/trait.rb', line 6

def block
  @block
end

Instance Method Details

#==(other) ⇒ Object



16
17
18
# File 'lib/action_factory/assignments/trait.rb', line 16

def ==(other)
  other.is_a?(self.class) && other.block == @block
end

#compile(factory) ⇒ Object



12
13
14
# File 'lib/action_factory/assignments/trait.rb', line 12

def compile(factory)
  factory.instance_exec(factory.instance, &@block)
end