Class: JsonApiModel::Model

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/json_api_model/model.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Model

Returns a new instance of Model.



31
32
33
# File 'lib/json_api_model/model.rb', line 31

def initialize( attributes = {} )
  @client = self.class.client_class.new( attributes )
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



35
36
37
# File 'lib/json_api_model/model.rb', line 35

def method_missing( m, *args, &block )
  client.send m, *args, &block
end

Class Attribute Details

.client_classObject (readonly)

Returns the value of attribute client_class.



8
9
10
# File 'lib/json_api_model/model.rb', line 8

def client_class
  @client_class
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



29
30
31
# File 'lib/json_api_model/model.rb', line 29

def client
  @client
end

Class Method Details

.connection(&block) ⇒ Object



18
19
20
# File 'lib/json_api_model/model.rb', line 18

def connection( &block )
  client_class.connection true, &block
end

.new_from_client(client) ⇒ Object



13
14
15
16
# File 'lib/json_api_model/model.rb', line 13

def new_from_client( client )
  model = new
  model.client = client
end

.wraps(client_class) ⇒ Object



9
10
11
# File 'lib/json_api_model/model.rb', line 9

def wraps( client_class )
  @client_class = client_class
end