Module: RestModel::Relation::Response

Included in:
RestModel::Relation
Defined in:
lib/rest_model/key/relation/response.rb

Instance Method Summary collapse

Instance Method Details

#to_relation(parent) ⇒ Object



11
12
13
14
15
16
# File 'lib/rest_model/key/relation/response.rb', line 11

def to_relation(parent)
  return nil unless visible?(parent)

  href = href(parent)
  href ? {rel: name, href: href} : nil
end

#to_resource(parent) ⇒ Object



4
5
6
7
8
9
# File 'lib/rest_model/key/relation/response.rb', line 4

def to_resource(parent)
  included = parent.__send__(name)
  return {} unless visible?(parent) and included

  {name => resource_from_included(included)}
end