Class: ROM::Factory::Attributes::Callable Private

Inherits:
Object
  • Object
show all
Defined in:
lib/rom/factory/attributes/callable.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, dsl, block) ⇒ Callable

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Callable.


10
11
12
13
14
# File 'lib/rom/factory/attributes/callable.rb', line 10

def initialize(name, dsl, block)
  @name = name
  @dsl = dsl
  @block = block
end

Instance Attribute Details

#blockObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


7
8
9
# File 'lib/rom/factory/attributes/callable.rb', line 7

def block
  @block
end

#dslObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


7
8
9
# File 'lib/rom/factory/attributes/callable.rb', line 7

def dsl
  @dsl
end

#nameObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


7
8
9
# File 'lib/rom/factory/attributes/callable.rb', line 7

def name
  @name
end

Instance Method Details

#call(attrs, *args) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


17
18
19
20
# File 'lib/rom/factory/attributes/callable.rb', line 17

def call(attrs, *args)
  result = attrs[name] || dsl.instance_exec(*args, &block)
  { name => result }
end

#dependency_namesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


28
29
30
# File 'lib/rom/factory/attributes/callable.rb', line 28

def dependency_names
  block.parameters.map(&:last)
end

#value?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

23
24
25
# File 'lib/rom/factory/attributes/callable.rb', line 23

def value?
  true
end