Class: Supple::DSL::DynamicTemplate

Inherits:
Object
  • Object
show all
Defined in:
lib/supple/model/dsl.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}, &block) ⇒ DynamicTemplate

Returns a new instance of DynamicTemplate.



35
36
37
38
39
40
# File 'lib/supple/model/dsl.rb', line 35

def initialize(name, options = {}, &block)
  @name = name
  @options = options
  @data = {}
  instance_eval(&block) if block_given?
end

Instance Method Details

#mapping(data = {}, &block) ⇒ Object



47
48
49
50
51
# File 'lib/supple/model/dsl.rb', line 47

def mapping(data = {}, &block)
  mapping = Mapping.new(data)
  mapping.instance_eval(&block) if block_given?
  @data[:mapping] = mapping.to_hash
end

#to_hashObject



53
54
55
56
# File 'lib/supple/model/dsl.rb', line 53

def to_hash
  @options[@name] = @data
  @options
end