Class: Iknow::Base
- Inherits:
-
Object
show all
- Defined in:
- lib/iknow/model/base.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.attributes ⇒ Object
3
|
# File 'lib/iknow/model/base.rb', line 3
def self.attributes; self::ATTRIBUTES end
|
.deserialize(response, params = {}) ⇒ Object
7
8
9
10
11
12
13
14
15
|
# File 'lib/iknow/model/base.rb', line 7
def self.deserialize(response, params = {})
return nil if response.is_a?(Hash) and
!response['error'].nil? and
response['error']['code'].to_i == 404
klass = params[:as] ? params[:as] : self
response.is_a?(Array) ? response.inject([]) { |results, params| results << klass.new(params) } :
klass.new(response)
end
|
Instance Method Details
#attributes ⇒ Object
5
|
# File 'lib/iknow/model/base.rb', line 5
def attributes; self.class.attributes end
|
#deserialize(response, params = {}) ⇒ Object
17
18
19
|
# File 'lib/iknow/model/base.rb', line 17
def deserialize(response, params = {})
self.class.deserialize(response, params)
end
|