Method: JSONFactory::JSONBuilder#element
- Defined in:
- lib/json_factory/json_builder.rb
#element(value = nil) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/json_factory/json_builder.rb', line 37 def element(value = nil) raise TypeNotAllowedError, 'Can only add an element within an array' unless type == :array add_separator if block_given? push_type(:value) { yield } else add_value(value) end increment_count end |