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
Returns a new instance of HasOne.
18 19 20 21 22 23 |
# File 'lib/jsonapi/association.rb', line 18 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 |