Class: JSONApi::Deserializer::Store
- Inherits:
-
Object
- Object
- JSONApi::Deserializer::Store
- Defined in:
- lib/jsonapi_deserializer.rb
Instance Method Summary collapse
- #get(type, id, lid) ⇒ Object
-
#initialize ⇒ Store
constructor
A new instance of Store.
- #set(type, id, lid, record) ⇒ Object
Constructor Details
#initialize ⇒ Store
Returns a new instance of Store.
43 44 45 |
# File 'lib/jsonapi_deserializer.rb', line 43 def initialize @db = {} end |
Instance Method Details
#get(type, id, lid) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/jsonapi_deserializer.rb', line 54 def get(type, id, lid) per_type = @db[type] return nil unless per_type identifier = id || lid per_type[identifier.to_s] end |
#set(type, id, lid, record) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/jsonapi_deserializer.rb', line 47 def set(type, id, lid, record) per_type = @db[type] ||= {} identifier = id || lid per_type[identifier.to_s] = record end |