Class: AdminAuth::Repository
- Inherits:
-
Object
- Object
- AdminAuth::Repository
- Defined in:
- lib/admin_auth/repository.rb
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
- #all ⇒ Object
- #create(attributes) ⇒ Object
- #destroy(id) ⇒ Object
- #find(attributes) ⇒ Object
-
#initialize ⇒ Repository
constructor
A new instance of Repository.
- #new(attributes = {}) ⇒ Object
- #update(id, attributes) ⇒ Object
Constructor Details
#initialize ⇒ Repository
Returns a new instance of Repository.
5 6 7 |
# File 'lib/admin_auth/repository.rb', line 5 def initialize @klass = ::Admin end |
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
3 4 5 |
# File 'lib/admin_auth/repository.rb', line 3 def klass @klass end |
Instance Method Details
#all ⇒ Object
9 10 11 |
# File 'lib/admin_auth/repository.rb', line 9 def all klass.all end |
#create(attributes) ⇒ Object
17 18 19 |
# File 'lib/admin_auth/repository.rb', line 17 def create(attributes) klass.create(attributes) end |
#destroy(id) ⇒ Object
32 33 34 |
# File 'lib/admin_auth/repository.rb', line 32 def destroy(id) find(id: id).destroy end |
#find(attributes) ⇒ Object
21 22 23 |
# File 'lib/admin_auth/repository.rb', line 21 def find(attributes) klass.where(attributes).first end |
#new(attributes = {}) ⇒ Object
13 14 15 |
# File 'lib/admin_auth/repository.rb', line 13 def new(attributes = {}) klass.new(attributes) end |
#update(id, attributes) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/admin_auth/repository.rb', line 25 def update(id, attributes) model = find(id: id) model.update_attributes(attributes) model end |