Class: Vedeu::API::Composition

Inherits:
Composition show all
Defined in:
lib/vedeu/api/composition.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Composition

#attributes, #interfaces, #to_s

Constructor Details

#initialize(&block) ⇒ Composition

Returns a new instance of Composition.



8
9
10
11
12
13
14
15
16
# File 'lib/vedeu/api/composition.rb', line 8

def initialize(&block)
  super

  if block_given?
    @self_before_instance_eval = eval('self', block.binding)

    instance_eval(&block)
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)



24
25
26
# File 'lib/vedeu/api/composition.rb', line 24

def method_missing(method, *args, &block)
  @self_before_instance_eval.send(method, *args, &block)
end

Class Method Details

.build(&block) ⇒ Object



4
5
6
# File 'lib/vedeu/api/composition.rb', line 4

def self.build(&block)
  new(&block).attributes
end

Instance Method Details

#view(name, &block) ⇒ Object



18
19
20
# File 'lib/vedeu/api/composition.rb', line 18

def view(name, &block)
  attributes[:interfaces] << Interface.build({ name: name }, &block)
end