Class: ObjectJSONMapper::Associations::Association Abstract
- Inherits:
-
Object
- Object
- ObjectJSONMapper::Associations::Association
- Defined in:
- lib/object_json_mapper/associations/association.rb
Overview
This class is abstract.
Base class for association builders
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
- #call ⇒ Object
- #endpoint ⇒ Object
-
#initialize(name, options = {}) ⇒ Association
constructor
A new instance of Association.
- #klass ⇒ Object
Constructor Details
#initialize(name, options = {}) ⇒ Association
Returns a new instance of Association.
14 15 16 17 18 19 |
# File 'lib/object_json_mapper/associations/association.rb', line 14 def initialize(name, = {}) @name = name @klass = .fetch(:class_name, name) @endpoint = .fetch(:endpoint, name) @params = .fetch(:params, {}) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/object_json_mapper/associations/association.rb', line 7 def name @name end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
7 8 9 |
# File 'lib/object_json_mapper/associations/association.rb', line 7 def params @params end |
Instance Method Details
#call ⇒ Object
21 22 23 |
# File 'lib/object_json_mapper/associations/association.rb', line 21 def call(*) raise NotImplementedError end |
#endpoint ⇒ Object
31 32 33 |
# File 'lib/object_json_mapper/associations/association.rb', line 31 def endpoint @endpoint.to_s.underscore end |
#klass ⇒ Object
25 26 27 28 29 |
# File 'lib/object_json_mapper/associations/association.rb', line 25 def klass return @klass.to_s.classify.constantize if @klass.is_a?(Symbol) @klass end |