Class: Lotus::Model::Adapters::Auth0::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/lotus/model/adapters/auth0/command.rb

Instance Method Summary collapse

Constructor Details

#initialize(_collection, _mapped_collection) ⇒ Command

Returns a new instance of Command.



9
10
11
12
# File 'lib/lotus/model/adapters/auth0/command.rb', line 9

def initialize(_collection, _mapped_collection)
  @collection         = _collection
  @mapped_collection  = _mapped_collection
end

Instance Method Details

#create(entity) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/lotus/model/adapters/auth0/command.rb', line 14

def create(entity)
  serialized_entity            = _serialize(entity)
  created_entity               = @collection.insert(serialized_entity)
  # oh no
  # @todo deep_symbolize_keys!
  created_entity               = eval(created_entity.to_s.gsub(/\"(\w+)\"(?==>)/, ':\1'))
  _deserialize(created_entity)
end

#delete(entity) ⇒ Object



30
31
32
33
# File 'lib/lotus/model/adapters/auth0/command.rb', line 30

def delete(entity)
  serialized_entity            = _serialize(entity)
  @collection.delete(serialized_entity)
end

#truncateObject



35
36
37
# File 'lib/lotus/model/adapters/auth0/command.rb', line 35

def truncate
  @collection.truncate
end

#update(entity) ⇒ Object



23
24
25
26
27
28
# File 'lib/lotus/model/adapters/auth0/command.rb', line 23

def update(entity)
  serialized_entity            = _serialize(entity)
  updated_entity               = @collection.update(serialized_entity)
  updated_entity               = eval(updated_entity.to_s.gsub(/\"(\w+)\"(?==>)/, ':\1'))
  _deserialize(updated_entity)
end