Class: Brainstem::Concerns::PresenterDSL::FieldsBlock

Inherits:
BaseBlock
  • Object
show all
Defined in:
lib/brainstem/dsl/fields_block.rb

Instance Attribute Summary

Attributes inherited from BaseBlock

#block_options, #configuration

Instance Method Summary collapse

Methods inherited from BaseBlock

#initialize, #with_options

Constructor Details

This class inherits a constructor from Brainstem::Concerns::PresenterDSL::BaseBlock

Instance Method Details

#field(name, type, options = {}) ⇒ Object



5
6
7
# File 'lib/brainstem/dsl/fields_block.rb', line 5

def field(name, type, options = {})
  configuration[name] = DSL::Field.new(name, type, smart_merge(block_options, format_options(options)))
end

#fields(name, type = :hash, options = {}, &block) ⇒ Object



9
10
11
12
13
14
# File 'lib/brainstem/dsl/fields_block.rb', line 9

def fields(name, type = :hash, options = {}, &block)
  nested_field = DSL::BlockField.for(name, type, smart_merge(block_options, format_options(options)), configuration[name])
  configuration[name] = nested_field

  descend self.class, nested_field.configuration, merge_parent_options(block_options, options), &block
end