Class: Actor::Build

Inherits:
Object
  • Object
show all
Defined in:
lib/actor/build.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cls, arguments, &block) ⇒ Build

Returns a new instance of Build.



7
8
9
10
11
# File 'lib/actor/build.rb', line 7

def initialize cls, arguments, &block
  @arguments = arguments
  @block = block
  @cls = cls
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



3
4
5
# File 'lib/actor/build.rb', line 3

def arguments
  @arguments
end

#blockObject (readonly)

Returns the value of attribute block.



4
5
6
# File 'lib/actor/build.rb', line 4

def block
  @block
end

#clsObject (readonly)

Returns the value of attribute cls.



5
6
7
# File 'lib/actor/build.rb', line 5

def cls
  @cls
end

Class Method Details

.call(cls, *arguments, &block) ⇒ Object



13
14
15
16
# File 'lib/actor/build.rb', line 13

def self.call cls, *arguments, &block
  instance = new cls, arguments, &block
  instance.()
end

Instance Method Details

#callObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/actor/build.rb', line 18

def call
  if cls.respond_to? :build
    method = cls.method :build
  else
    method = cls.method :new
  end

  if block
    actor = method.(*arguments, &block)
  else
    actor = method.(*arguments)
  end

  actor.configure

  actor
end