Class: JSONAPI::Association::HasOne

Inherits:
JSONAPI::Association show all
Defined in:
lib/jsonapi/association.rb

Instance Attribute Summary

Attributes inherited from JSONAPI::Association

#acts_as_set, #class_name, #key, #name, #options, #primary_key, #type

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of HasOne.



14
15
16
17
18
19
# File 'lib/jsonapi/association.rb', line 14

def initialize(name, options={})
  super
  @class_name = options.fetch(:class_name, name.to_s.capitalize)
  @type = class_name.underscore.pluralize.to_sym
  @key ||= "#{name}_id".to_sym
end