Class: Ki::Model
- Inherits:
-
Object
- Object
- Ki::Model
- Extended by:
- QueryInterface, Restrictions
- Includes:
- Ki::Middleware::Helpers::RedirectTo, Callbacks, ModelHelper
- Defined in:
- lib/ki/model.rb,
lib/ki/modules/callbacks.rb,
lib/ki/modules/model_helper.rb,
lib/ki/modules/restrictions.rb,
lib/ki/modules/query_interface.rb
Defined Under Namespace
Modules: Callbacks, ModelHelper, QueryInterface, Restrictions
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#params ⇒ Object
Returns the value of attribute params.
-
#req ⇒ Object
Returns the value of attribute req.
-
#result ⇒ Object
Returns the value of attribute result.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #create ⇒ Object
- #delete ⇒ Object
- #find ⇒ Object
-
#initialize(req) ⇒ Model
constructor
A new instance of Model.
- #update ⇒ Object
Methods included from QueryInterface
class_name, count, find_or_create
Methods included from Restrictions
forbid, forbidden_actions, required_attributes, requires, unique, unique_attributes
Methods included from Ki::Middleware::Helpers::RedirectTo
Methods included from ModelHelper
#delete?, #forbidden_actions, #get?, #post?, #put?, #required_attributes, #skipped_params, #unique_attributes
Methods included from Callbacks
#after_all, #after_create, #after_delete, #after_find, #after_update, #before_all, #before_create, #before_delete, #before_find, #before_update
Constructor Details
#initialize(req) ⇒ Model
Returns a new instance of Model.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ki/model.rb', line 11 def initialize(req) @req = req @action = req.to_action @params = req.params @status = 200 fail ForbiddenAction if forbidden_actions.include? @action ccall end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
9 10 11 |
# File 'lib/ki/model.rb', line 9 def action @action end |
#params ⇒ Object
Returns the value of attribute params.
9 10 11 |
# File 'lib/ki/model.rb', line 9 def params @params end |
#req ⇒ Object
Returns the value of attribute req.
9 10 11 |
# File 'lib/ki/model.rb', line 9 def req @req end |
#result ⇒ Object
Returns the value of attribute result.
9 10 11 |
# File 'lib/ki/model.rb', line 9 def result @result end |
#status ⇒ Object
Returns the value of attribute status.
9 10 11 |
# File 'lib/ki/model.rb', line 9 def status @status end |
Instance Method Details
#create ⇒ Object
26 27 28 29 30 |
# File 'lib/ki/model.rb', line 26 def create check_for_required_attributes check_for_unique_attributes @result = self.class.create @params end |
#delete ⇒ Object
38 39 40 |
# File 'lib/ki/model.rb', line 38 def delete @result = self.class.delete @params end |
#find ⇒ Object
22 23 24 |
# File 'lib/ki/model.rb', line 22 def find @result = self.class.find @params end |
#update ⇒ Object
32 33 34 35 36 |
# File 'lib/ki/model.rb', line 32 def update check_for_required_attributes check_for_unique_attributes @result = self.class.update @params end |