Class: OpenStruct

Inherits:
Object show all
Defined in:
lib/lite/ruby/open_struct.rb

Instance Method Summary collapse

Instance Method Details

#attributesObject



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