Class: Json::Streamer::Callbacks
- Inherits:
-
Object
- Object
- Json::Streamer::Callbacks
- Defined in:
- lib/json/streamer/callbacks.rb
Instance Attribute Summary collapse
-
#aggregator ⇒ Object
readonly
Returns the value of attribute aggregator.
Instance Method Summary collapse
- #end_array ⇒ Object
- #end_object ⇒ Object
-
#initialize(aggregator) ⇒ Callbacks
constructor
A new instance of Callbacks.
- #key(k, symbolize_keys) ⇒ Object
- #start_array ⇒ Object
- #start_object ⇒ Object
- #value(value) ⇒ Object
Constructor Details
#initialize(aggregator) ⇒ Callbacks
Returns a new instance of Callbacks.
6 7 8 |
# File 'lib/json/streamer/callbacks.rb', line 6 def initialize(aggregator) @aggregator = aggregator end |
Instance Attribute Details
#aggregator ⇒ Object (readonly)
Returns the value of attribute aggregator.
4 5 6 |
# File 'lib/json/streamer/callbacks.rb', line 4 def aggregator @aggregator end |
Instance Method Details
#end_array ⇒ Object
31 32 33 |
# File 'lib/json/streamer/callbacks.rb', line 31 def end_array end_level { |obj| yield obj } end |
#end_object ⇒ Object
27 28 29 |
# File 'lib/json/streamer/callbacks.rb', line 27 def end_object end_level { |obj| yield obj } end |
#key(k, symbolize_keys) ⇒ Object
18 19 20 |
# File 'lib/json/streamer/callbacks.rb', line 18 def key(k, symbolize_keys) @aggregator.key = symbolize_keys ? k.to_sym : k end |
#start_array ⇒ Object
14 15 16 |
# File 'lib/json/streamer/callbacks.rb', line 14 def start_array new_level(Array.new) end |
#start_object ⇒ Object
10 11 12 |
# File 'lib/json/streamer/callbacks.rb', line 10 def start_object new_level(Hash.new) end |
#value(value) ⇒ Object
22 23 24 25 |
# File 'lib/json/streamer/callbacks.rb', line 22 def value(value) used = yield value add_value(value) unless used end |