Class: OpenStruct
Instance Method Summary collapse
- #attributes ⇒ Object
- #replace(args) ⇒ Object
- #to_hash(table: true) ⇒ Object (also: #to_h)
- #to_json(table: true) ⇒ Object (also: #as_json)
Instance Method Details
#attributes ⇒ Object
8 9 10 |
# File 'lib/lite/ruby/open_struct.rb', line 8 def attributes @table end |
#replace(args) ⇒ Object
12 13 14 |
# File 'lib/lite/ruby/open_struct.rb', line 12 def replace(args) args.each { |key, val| self[key] = val } end |
#to_hash(table: true) ⇒ Object Also known as: to_h
16 17 18 19 20 |
# File 'lib/lite/ruby/open_struct.rb', line 16 def to_hash(table: true) return attributes unless table { table: attributes } end |
#to_json(table: true) ⇒ Object Also known as: as_json
22 23 24 |
# File 'lib/lite/ruby/open_struct.rb', line 22 def to_json(table: true) to_hash(table: table).to_json end |