Sha256: efa29991432ef48294938bc5afb38a74c860d1ead92b7886695da56a4e4b7b69
Contents?: true
Size: 924 Bytes
Versions: 16
Compression:
Stored size: 924 Bytes
Contents
# OpenStruct `attributes` ------ Returns the key values as a hash of the assigned struct. ```ruby person = OpenStruct.new(name: 'bob', age: 60) person.attributes #=> { name: 'bob', age: 60 } ``` `replace` ------ Replaces values provided within the hash. ```ruby person = OpenStruct.new(name: 'bob', age: 60) person.replace(name: 'tom', age: 28) preson.name #=> 'tom' ``` `to_hash` aka `to_h` ------ Returns the key values as a hash of the assigned struct. ```ruby person = OpenStruct.new(name: 'bob', age: 60) person.to_hash #=> { table: { name: 'bob', age: 60 } } person.to_hash(table: false) #=> { name: 'bob', age: 60 } ``` `to_json` aka `as_json` ------ Returns the key values as Json of the assigned struct. ```ruby person = OpenStruct.new(name: 'bob', age: 60) person.to_json #=> { table: { name: 'bob', age: 60 } } person.to_json(table: false) #=> { name: 'bob', age: 60 } ```
Version data entries
16 entries across 16 versions & 1 rubygems