Class: Builder::JsonFormat
- Inherits:
-
HashStructure
- Object
- Abstract
- HashStructure
- Builder::JsonFormat
- Defined in:
- lib/builder/json_format.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ JsonFormat
constructor
A new instance of JsonFormat.
- #target! ⇒ Object
Methods inherited from HashStructure
#<<, #array_mode, #content!, #method_missing, #root!, #tag!, #text!
Methods inherited from Abstract
#comment!, #declare!, #instruct!, #nil?
Constructor Details
#initialize(options = {}) ⇒ JsonFormat
Returns a new instance of JsonFormat.
6 7 8 9 10 11 12 13 |
# File 'lib/builder/json_format.rb', line 6 def initialize( = {}) # @default_content_key is used in such case: markup.key(value, :attr_key => attr_value) # in this case, we need some key for value. @default_content_key = ([:default_content_key] || :content).to_sym @include_root = [:include_root] @target = {} @array_mode = false end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Builder::HashStructure
Instance Method Details
#target! ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/builder/json_format.rb', line 15 def target! if @include_root @target.to_json else @target[@root].to_json end end |