Class: Iknow::Base
- Inherits:
-
Object
show all
- Defined in:
- lib/iknow/model/base.rb
Direct Known Subclasses
Item, Item::Cue, Item::Response, List, List::Application, Sentence, User, User::Profile, User::Study, User::Study::Result, User::Study::TotalSummary
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(hash, params = {}) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/iknow/model/base.rb', line 7
def self.deserialize(hash, params = {})
return nil if hash.nil?
klass = params[:as] ? params[:as] : self
if hash.is_a?(Array)
hash.inject([]) { |results, hash|
hash.symbolize_keys!
results << klass.new(hash)
}
else
hash.symbolize_keys!
klass.new(hash)
end
end
|
Instance Method Details
#attributes ⇒ Object
5
|
# File 'lib/iknow/model/base.rb', line 5
def attributes; self.class.attributes end
|
#deserialize(hash, params = {}) ⇒ Object
22
23
24
|
# File 'lib/iknow/model/base.rb', line 22
def deserialize(hash, params = {})
self.class.deserialize(hash, params)
end
|