Module: Hipbot::Storages::Hash
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/hipbot/storages/hash.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #destroy ⇒ Object
- #id ⇒ Object
- #initialize(params = {}) ⇒ Object
- #name ⇒ Object
- #name=(value) ⇒ Object
- #update_attribute(key, value) ⇒ Object
- #update_attributes(hash) ⇒ Object
Instance Method Details
#destroy ⇒ Object
39 40 41 |
# File 'lib/hipbot/storages/hash.rb', line 39 def destroy self.class.collection.delete(id) end |
#id ⇒ Object
17 18 19 |
# File 'lib/hipbot/storages/hash.rb', line 17 def id attributes[:id] end |
#initialize(params = {}) ⇒ Object
13 14 15 |
# File 'lib/hipbot/storages/hash.rb', line 13 def initialize params = {} self.attributes = params.with_indifferent_access end |
#name ⇒ Object
21 22 23 |
# File 'lib/hipbot/storages/hash.rb', line 21 def name attributes[:name] end |
#name=(value) ⇒ Object
25 26 27 |
# File 'lib/hipbot/storages/hash.rb', line 25 def name= value update_attribute(:name, value) end |
#update_attribute(key, value) ⇒ Object
29 30 31 |
# File 'lib/hipbot/storages/hash.rb', line 29 def update_attribute key, value self.attributes[key] = value end |
#update_attributes(hash) ⇒ Object
33 34 35 36 37 |
# File 'lib/hipbot/storages/hash.rb', line 33 def update_attributes hash hash.each do |k, v| update_attribute k, v end end |