Class: JSONAPI::Association::HasOne
- Inherits:
-
JSONAPI::Association
- Object
- JSONAPI::Association
- JSONAPI::Association::HasOne
- Defined in:
- lib/jsonapi/association.rb
Instance Attribute Summary
Attributes inherited from JSONAPI::Association
#acts_as_set, #class_name, #foreign_key, #name, #options, #type
Instance Method Summary collapse
-
#initialize(name, options = {}) ⇒ HasOne
constructor
A new instance of HasOne.
Methods inherited from JSONAPI::Association
Constructor Details
#initialize(name, options = {}) ⇒ HasOne
25 26 27 28 29 30 |
# File 'lib/jsonapi/association.rb', line 25 def initialize(name, ={}) super @class_name = .fetch(:class_name, name.to_s.capitalize) @type = class_name.underscore.pluralize.to_sym @foreign_key ||= @key.nil? ? "#{name}_id".to_sym : @key end |