Class: JSONAPI::Relationship::ToMany

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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