Class: JsonApiModel::Model
- Inherits:
-
Object
- Object
- JsonApiModel::Model
show all
- Extended by:
- Forwardable
- Defined in:
- lib/json_api_model/model.rb
Constant Summary
collapse
- RESERVED_FIELDS =
[ :type, :id ]
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.
32
33
34
|
# File 'lib/json_api_model/model.rb', line 32
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
36
37
38
|
# File 'lib/json_api_model/model.rb', line 36
def method_missing( m, *args, &block )
client.send m, *args, &block
end
|
Class Attribute Details
.client_class ⇒ Object
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
#client ⇒ Object
Returns the value of attribute client.
30
31
32
|
# File 'lib/json_api_model/model.rb', line 30
def client
@client
end
|
Class Method Details
.connection(&block) ⇒ Object
19
20
21
|
# File 'lib/json_api_model/model.rb', line 19
def connection( &block )
client_class.connection true, &block
end
|
.new_from_client(client) ⇒ Object
13
14
15
16
17
|
# File 'lib/json_api_model/model.rb', line 13
def new_from_client( client )
model = new
model.client = client
model
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
|
Instance Method Details
#as_json ⇒ Object
40
41
42
|
# File 'lib/json_api_model/model.rb', line 40
def as_json
client.as_json
end
|