Method: ActiveCouch::Base.from_json
- Defined in:
- lib/active_couch/base.rb
.from_json(json) ⇒ Object
Initializes an object of a subclass of ActiveCouch::Base based on a JSON representation of the object.
Example:
class Person < ActiveCouch::Base
has :name
end
person = Person.from_json('{"name":"McLovin"}')
person.name # "McLovin"
266 267 268 269 270 |
# File 'lib/active_couch/base.rb', line 266 def from_json(json) hash = JSON.parse(json) # Create new based on parsed self.new(hash) end |