Module: C3DCI::DCI::DSL

Defined in:
lib/c3-dci/dci/dsl.rb

Instance Method Summary collapse

Instance Method Details

#context(name, &block) ⇒ Object



27
28
29
30
31
32
# File 'lib/c3-dci/dci/dsl.rb', line 27

def context name, &block
  klass_name = camelize_me! "#{name.to_s}_context"
  klass      = Class.new ::C3DCI::DCI::Type::Context, &block
  parent, child = parent_and_child klass_name
  parent.const_set child, klass
end

#data(name, &block) ⇒ Object

you can also use your basic model type this is a nice helper for POROs



9
10
11
12
13
14
# File 'lib/c3-dci/dci/dsl.rb', line 9

def data name, &block
  klass_name = camelize_me! "#{name.to_s}_data"
  klass      = Class.new ::C3DCI::DCI::Type::Data, &block
  parent, child = parent_and_child klass_name
  parent.const_set child, klass
end

#role(name, &block) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/c3-dci/dci/dsl.rb', line 16

def role name, &block
  module_name = camelize_me! "#{name.to_s}_role"
  module_defs = Module.new do
    include ::C3DCI::DCI::Type::Role
  end
  module_defs.module_eval &block
  parent, child = parent_and_child module_name
  parent.const_set child, module_defs
end