Module: Core::Io::Json::Grammar::Intermediate
- Included in:
- Endpoint::BasicHandler::Associations::BelongsTo::Handler::Association, Actions, Node, Root
- Defined in:
- app/api/core/io/json/grammar.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
Instance Method Summary collapse
- #[](name) ⇒ Object
- #call(object, options, stream) ⇒ Object
- #initialize(children) ⇒ Object
-
#inspect ⇒ Object
rubocop:enable Metrics/MethodLength.
- #leaf(name, attribute) ⇒ Object
- #merge(node) {|node.merge_children_with(self)| ... } ⇒ Object
-
#merge_children_with(node) ⇒ Object
rubocop:todo Metrics/MethodLength.
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
4 5 6 |
# File 'app/api/core/io/json/grammar.rb', line 4 def children @children end |
Instance Method Details
#[](name) ⇒ Object
14 15 16 |
# File 'app/api/core/io/json/grammar.rb', line 14 def [](name) @children[name] ||= Node.new(name) end |
#call(object, options, stream) ⇒ Object
18 19 20 |
# File 'app/api/core/io/json/grammar.rb', line 18 def call(object, , stream) process_children(object, , stream) end |
#initialize(children) ⇒ Object
6 7 8 |
# File 'app/api/core/io/json/grammar.rb', line 6 def initialize(children) @children = children || {} end |
#inspect ⇒ Object
rubocop:enable Metrics/MethodLength
54 55 56 |
# File 'app/api/core/io/json/grammar.rb', line 54 def inspect @children.values.inspect end |
#leaf(name, attribute) ⇒ Object
10 11 12 |
# File 'app/api/core/io/json/grammar.rb', line 10 def leaf(name, attribute) @children[name] ||= Leaf.new(name, attribute) end |
#merge(node) {|node.merge_children_with(self)| ... } ⇒ Object
27 28 29 |
# File 'app/api/core/io/json/grammar.rb', line 27 def merge(node) yield(node.merge_children_with(self)) end |
#merge_children_with(node) ⇒ Object
rubocop:todo Metrics/MethodLength
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/api/core/io/json/grammar.rb', line 32 def merge_children_with(node) # rubocop:todo Metrics/AbcSize (node.children.keys + @children.keys) .uniq .each_with_object({}) do |k, store| cloned = case when @children.key?(k) && node.children.key?(k) node.children[k].merge(@children[k]) when @children.key?(k) @children[k] when node.children.key?(k) node.children[k] else raise 'Odd, how did that happen?' end store[k] = cloned end end |