Module: Kashmir::Dsl::ClassMethods

Defined in:
lib/kashmir/dsl.rb

Instance Method Summary collapse

Instance Method Details

#definitionsObject



35
36
37
38
# File 'lib/kashmir/dsl.rb', line 35

def definitions
  @definitions ||= []
  @definitions
end

#embed(name, representer) ⇒ Object



26
27
28
# File 'lib/kashmir/dsl.rb', line 26

def embed(name, representer)
  group(name, representer.definitions) 
end

#group(name, fields) ⇒ Object



20
21
22
23
24
# File 'lib/kashmir/dsl.rb', line 20

def group(name, fields)
  definition = Hash.new
  definition[name] = fields
  definitions << definition
end

#inline(name, &inline_representer) ⇒ Object



30
31
32
33
# File 'lib/kashmir/dsl.rb', line 30

def inline(name, &inline_representer)
  representer = Kashmir::InlineDsl.build(&inline_representer)
  embed(name, representer) 
end

#prop(name) ⇒ Object



10
11
12
# File 'lib/kashmir/dsl.rb', line 10

def prop(name)
  definitions << name
end

#props(*names) ⇒ Object



14
15
16
17
18
# File 'lib/kashmir/dsl.rb', line 14

def props(*names)
  names.each do |name|
    prop(name)
  end
end