Class: Supple::DSL::DynamicTemplate
- Inherits:
-
Object
- Object
- Supple::DSL::DynamicTemplate
- Defined in:
- lib/supple/model/dsl.rb
Instance Method Summary collapse
-
#initialize(name, options = {}, &block) ⇒ DynamicTemplate
constructor
A new instance of DynamicTemplate.
- #mapping(data = {}, &block) ⇒ Object
- #to_hash ⇒ Object
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, = {}, &block) @name = name @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_hash ⇒ Object
53 54 55 56 |
# File 'lib/supple/model/dsl.rb', line 53 def to_hash @options[@name] = @data @options end |