Class: Streama::DefinitionDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/streama/definition_dsl.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ DefinitionDSL

Returns a new instance of DefinitionDSL.



7
8
9
10
11
12
13
14
# File 'lib/streama/definition_dsl.rb', line 7

def initialize(name)
  @attributes = {
    :name => name.to_sym,
    :actor => {},
    :object => {},
    :target_object => {}
  }
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/streama/definition_dsl.rb', line 5

def attributes
  @attributes
end

Class Method Details

.data_methods(*args) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/streama/definition_dsl.rb', line 18

def self.data_methods(*args)
  args.each do |method|
    define_method method do |*args|
      class_sym = if class_name = args[1].try(:delete,:class_name)
                    class_name.underscore.to_sym
                  else
                    args[0].is_a?(Symbol) ? args[0] : args[0].class.to_sym
                  end
      @attributes[method].store(class_sym, args[1])
    end
  end
end