Class: JSONAPI::Relationship::ToMany

Inherits:
JSONAPI::Relationship show all
Defined in:
lib/jsonapi/relationship.rb

Instance Attribute Summary collapse

Attributes inherited from JSONAPI::Relationship

#acts_as_set, #always_include_linkage_data, #class_name, #eager_load_on_include, #foreign_key, #name, #options, #parent_resource, #polymorphic

Instance Method Summary collapse

Methods inherited from JSONAPI::Relationship

#belongs_to?, #primary_key, #relation_name, #resource_klass, #table_name, #type, #type_for_source

Constructor Details

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

Returns a new instance of ToMany.



85
86
87
88
89
90
91
# File 'lib/jsonapi/relationship.rb', line 85

def initialize(name, options = {})
  super
  @class_name = options.fetch(:class_name, name.to_s.camelize.singularize)
  @foreign_key ||= "#{name.to_s.singularize}_ids".to_sym
  @reflect = options.fetch(:reflect, true) == true
  @inverse_relationship = options.fetch(:inverse_relationship, parent_resource._type.to_s.singularize.to_sym) if parent_resource
end

Instance Attribute Details

#inverse_relationshipObject (readonly)

Returns the value of attribute inverse_relationship.



83
84
85
# File 'lib/jsonapi/relationship.rb', line 83

def inverse_relationship
  @inverse_relationship
end

#reflectObject (readonly)

Returns the value of attribute reflect.



83
84
85
# File 'lib/jsonapi/relationship.rb', line 83

def reflect
  @reflect
end