Class: JsonApiResource::Associations::HasMany

Inherits:
Base
  • Object
show all
Defined in:
lib/json_api_resource/associations/has_many.rb

Instance Attribute Summary

Attributes inherited from Base

#action, #key, #name, #root

Instance Method Summary collapse

Methods inherited from Base

#default_nil, #initialize, #klass, #opts, #post_process

Constructor Details

This class inherits a constructor from JsonApiResource::Associations::Base

Instance Method Details

#callable?(root_instance) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/json_api_resource/associations/has_many.rb', line 13

def callable?( root_instance )
  true
end

#default_actionObject



4
5
6
# File 'lib/json_api_resource/associations/has_many.rb', line 4

def default_action
  :where
end

#query(root_instance) ⇒ Object



17
18
19
# File 'lib/json_api_resource/associations/has_many.rb', line 17

def query( root_instance )
  { key => root_instance.id }.merge(opts)
end

#server_keyObject



8
9
10
11
# File 'lib/json_api_resource/associations/has_many.rb', line 8

def server_key
  class_name = self.root.to_s.demodulize.underscore
  "#{class_name}_id"
end

#typeObject



21
22
23
# File 'lib/json_api_resource/associations/has_many.rb', line 21

def type
  JsonApiResource::Associations::HAS_MANY
end