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
7 8 9 |
# File 'lib/lite/ruby/open_struct.rb', line 7 def attributes @table end |
#replace(args) ⇒ Object
11 12 13 |
# File 'lib/lite/ruby/open_struct.rb', line 11 def replace(args) args.each { |key, val| self[key] = val } end |
#to_hash(table: true) ⇒ Object Also known as: to_h
15 16 17 18 19 |
# File 'lib/lite/ruby/open_struct.rb', line 15 def to_hash(table: true) return attributes unless table { table: attributes } end |
#to_json(table: true) ⇒ Object Also known as: as_json
21 22 23 |
# File 'lib/lite/ruby/open_struct.rb', line 21 def to_json(table: true) to_hash(table: table).to_json end |