Class: RestModel::Embeddable

Inherits:
Association show all
Includes:
Retriever, Sender, Response
Defined in:
lib/rest_model/key/embeddable.rb,
lib/rest_model/key/embeddable/sender.rb,
lib/rest_model/key/embeddable/builder.rb,
lib/rest_model/key/embeddable/response.rb,
lib/rest_model/key/embeddable/retriever.rb

Defined Under Namespace

Modules: Builder, Response, Retriever, Sender

Instance Attribute Summary collapse

Attributes inherited from Association

#many

Attributes inherited from Key

#model, #name, #options, #summarize

Instance Method Summary collapse

Methods included from Response

#build_links, #resource, #resource_keys, #summarize?

Methods included from Retriever

#digg, #from_source, #handle_fields

Methods included from Sender

#to_source!

Methods inherited from Association

#default_class_name, #many?, #one?, #resource_class

Methods inherited from Key

#convert_input_keys, #present?, #relation?, #root_path?, #source_path, #visible?

Constructor Details

#initialize(name, options = {}) ⇒ Embeddable

Returns a new instance of Embeddable.



12
13
14
15
16
17
18
19
# File 'lib/rest_model/key/embeddable.rb', line 12

def initialize(name, options = {})
  super

  if fields = options[:fields]
    @class_name = :array
    @fields = fields
  end
end

Instance Attribute Details

#fieldsObject

Returns the value of attribute fields.



10
11
12
# File 'lib/rest_model/key/embeddable.rb', line 10

def fields
  @fields
end

Instance Method Details

#from_hash(attrs, resource = nil) ⇒ Object



25
26
27
# File 'lib/rest_model/key/embeddable.rb', line 25

def from_hash(attrs, resource = nil)
  raw? ? attrs : super
end

#raw?Boolean

Returns:



21
22
23
# File 'lib/rest_model/key/embeddable.rb', line 21

def raw?
  %w(Hash Array).include?(@class_name.to_s.camelize)
end