Class: SimpleFactory::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_factory/definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, value_or_callable) ⇒ Definition

Returns a new instance of Definition.



5
6
7
8
# File 'lib/simple_factory/definition.rb', line 5

def initialize(name, value_or_callable)
  @name = name
  @value_or_callable = value_or_callable
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/simple_factory/definition.rb', line 3

def name
  @name
end

Instance Method Details

#valueObject



10
11
12
13
14
15
16
# File 'lib/simple_factory/definition.rb', line 10

def value
  if @value_or_callable.respond_to?(:call)
    @value_or_callable.call
  else
    @value_or_callable
  end
end