Method: JSONAPI::Relationship::ToMany#initialize

Defined in:
lib/jsonapi/relationship.rb

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

Returns a new instance of ToMany.



192
193
194
195
196
197
198
199
200
# File 'lib/jsonapi/relationship.rb', line 192

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
  if parent_resource
    @inverse_relationship = options.fetch(:inverse_relationship, parent_resource._type.to_s.singularize.to_sym)
  end
end