Class: JsonApiModel::Associations::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/json_api_model/associations/base.rb

Direct Known Subclasses

BelongsTo, Has

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_class, name, opts = {}) ⇒ Base

Returns a new instance of Base.



7
8
9
10
11
12
13
# File 'lib/json_api_model/associations/base.rb', line 7

def initialize( base_class, name, opts = {} )
  self.name = name
  self.opts = opts
  self.key  = idify( base_class )

  sanitize_opts( base_class )
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



5
6
7
# File 'lib/json_api_model/associations/base.rb', line 5

def key
  @key
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/json_api_model/associations/base.rb', line 5

def name
  @name
end

#optsObject

Returns the value of attribute opts.



5
6
7
# File 'lib/json_api_model/associations/base.rb', line 5

def opts
  @opts
end

Instance Method Details

#fetch(instance) ⇒ Object



15
16
17
# File 'lib/json_api_model/associations/base.rb', line 15

def fetch( instance )
  process klass.send( action, query( instance ) )
end