Class: JSONAPI::Relationship::ToMany
- Inherits:
-
JSONAPI::Relationship
- Object
- JSONAPI::Relationship
- JSONAPI::Relationship::ToMany
- Defined in:
- lib/jsonapi/relationship.rb
Instance Attribute Summary collapse
-
#inverse_relationship ⇒ Object
readonly
Returns the value of attribute inverse_relationship.
-
#reflect ⇒ Object
readonly
Returns the value of attribute reflect.
Attributes inherited from JSONAPI::Relationship
#acts_as_set, #always_include_linkage_data, #class_name, #eager_load_on_include, #foreign_key, #name, #options, #parent_resource, #polymorphic
Instance Method Summary collapse
-
#initialize(name, options = {}) ⇒ ToMany
constructor
A new instance of ToMany.
- #to_s ⇒ Object
Methods inherited from JSONAPI::Relationship
#_exclude_links, #belongs_to?, #exclude_link?, #exclude_links, #primary_key, #relation_name, #resource_klass, #table_name, #type, #type_for_source
Constructor Details
#initialize(name, options = {}) ⇒ ToMany
Returns a new instance of ToMany.
114 115 116 117 118 119 120 |
# File 'lib/jsonapi/relationship.rb', line 114 def initialize(name, = {}) super @class_name = .fetch(:class_name, name.to_s.camelize.singularize) @foreign_key ||= "#{name.to_s.singularize}_ids".to_sym @reflect = .fetch(:reflect, true) == true @inverse_relationship = .fetch(:inverse_relationship, parent_resource._type.to_s.singularize.to_sym) if parent_resource end |
Instance Attribute Details
#inverse_relationship ⇒ Object (readonly)
Returns the value of attribute inverse_relationship.
112 113 114 |
# File 'lib/jsonapi/relationship.rb', line 112 def inverse_relationship @inverse_relationship end |
#reflect ⇒ Object (readonly)
Returns the value of attribute reflect.
112 113 114 |
# File 'lib/jsonapi/relationship.rb', line 112 def reflect @reflect end |
Instance Method Details
#to_s ⇒ Object
122 123 124 125 126 |
# File 'lib/jsonapi/relationship.rb', line 122 def to_s # :nocov: "#{parent_resource}.#{name}(ToMany)" # :nocov: end |