Module: MmAdapter::ClassMethods
- Defined in:
- lib/models/mm_adapter.rb
Instance Method Summary collapse
- #all ⇒ Object
- #delete(pk) ⇒ Object
- #get(hash) ⇒ Object
- #set(attributes) ⇒ Object
- #set!(attributes) ⇒ Object
Instance Method Details
#all ⇒ Object
8 9 10 11 |
# File 'lib/models/mm_adapter.rb', line 8 def all result = MmUser.all result.collect {|instance| self.new instance} end |
#delete(pk) ⇒ Object
36 37 38 39 |
# File 'lib/models/mm_adapter.rb', line 36 def delete(pk) user = User.first(:id => pk) user.destroy end |
#get(hash) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/models/mm_adapter.rb', line 13 def get(hash) if user = MmUser.first(hash) self.new user else nil end end |
#set(attributes) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/models/mm_adapter.rb', line 21 def set(attributes) puts attributes.inspect user = MmUser.new attributes puts user.inspect puts user.to_json user.id = nil unless user.save user end |
#set!(attributes) ⇒ Object
30 31 32 33 34 |
# File 'lib/models/mm_adapter.rb', line 30 def set!(attributes) user = MmUser.new attributes user.save! user end |