Class: Props::DebugWriter
- Inherits:
-
Object
- Object
- Props::DebugWriter
- Defined in:
- lib/props_template/debug_writer.rb
Instance Attribute Summary collapse
-
#commands ⇒ Object
Returns the value of attribute commands.
Instance Method Summary collapse
-
#initialize(opts) ⇒ DebugWriter
constructor
A new instance of DebugWriter.
- #pop ⇒ Object
- #push_array ⇒ Object
- #push_key(key) ⇒ Object
- #push_object ⇒ Object
- #push_value(value, key = nil) ⇒ Object
- #reset ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(opts) ⇒ DebugWriter
Returns a new instance of DebugWriter.
9 10 11 12 |
# File 'lib/props_template/debug_writer.rb', line 9 def initialize(opts) @stream = Oj::StringWriter.new(opts) @commands = [] end |
Instance Attribute Details
#commands ⇒ Object
Returns the value of attribute commands.
7 8 9 |
# File 'lib/props_template/debug_writer.rb', line 7 def commands @commands end |
Instance Method Details
#pop ⇒ Object
34 35 36 |
# File 'lib/props_template/debug_writer.rb', line 34 def pop @commands.push([:pop]) end |
#push_array ⇒ Object
30 31 32 |
# File 'lib/props_template/debug_writer.rb', line 30 def push_array @commands.push([:push_array]) end |
#push_key(key) ⇒ Object
18 19 20 |
# File 'lib/props_template/debug_writer.rb', line 18 def push_key(key) @commands.push([:push_key, key]) end |
#push_object ⇒ Object
14 15 16 |
# File 'lib/props_template/debug_writer.rb', line 14 def push_object @commands.push([:push_object]) end |
#push_value(value, key = nil) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/props_template/debug_writer.rb', line 22 def push_value(value, key = nil) if key @commands.push([:push_value, value, key]) else @commands.push([:push_value, value]) end end |
#reset ⇒ Object
38 39 40 41 |
# File 'lib/props_template/debug_writer.rb', line 38 def reset @commands = [] @stream.reset end |
#to_s ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/props_template/debug_writer.rb', line 43 def to_s @commands.each do |command| begin @stream.send(*command) rescue => e byebug end end @stream.to_s end |