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.
42 43 44 |
# File 'lib/jsonapi_deserializer.rb', line 42 def initialize @db = {} end |
Instance Method Details
#get(type, id, lid) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/jsonapi_deserializer.rb', line 53 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
46 47 48 49 50 51 |
# File 'lib/jsonapi_deserializer.rb', line 46 def set(type, id, lid, record) per_type = @db[type] ||= {} identifier = id || lid per_type[identifier.to_s] = record end |