class ObjectJSONMapper::Associations::Association

Base class for association builders

@abstract

Attributes

name[R]
params[R]

Public Class Methods

new(name, options = {}) click to toggle source

@param name [Symbol] @param options [Hash] @option options [Object] :klass @option options [String] :endpoint @option options [Hash] :params

# File lib/object_json_mapper/associations/association.rb, line 14
def initialize(name, options = {})
  @name     = name
  @klass    = options.fetch(:class_name, name)
  @endpoint = options.fetch(:endpoint, name)
  @params   = options.fetch(:params, {})
end

Public Instance Methods

call(*) click to toggle source
# File lib/object_json_mapper/associations/association.rb, line 21
def call(*)
  raise NotImplementedError
end
endpoint() click to toggle source
# File lib/object_json_mapper/associations/association.rb, line 31
def endpoint
  @endpoint.to_s.underscore
end
klass() click to toggle source
# 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