Module: ONEAccess::Serializable

Instance Method Summary collapse

Instance Method Details

#from_json(json) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/oneaccess/serializable.rb', line 9

def from_json(json)
  if collection?
    collection = []
    @representer_class.new(collection).from_json(json)
    collection
  else
    obj = new
    @representer_class.new(obj).from_json(json)
    obj
  end
end

#represented_by(representer_class) ⇒ Object



5
6
7
# File 'lib/oneaccess/serializable.rb', line 5

def represented_by(representer_class)
  @representer_class = representer_class
end