Class: Ki::Model
- Extended by:
- Descendants, 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 Descendants
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.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ki/model.rb', line 16 def initialize(req) @req = req @action = req.to_action @params = req.params @status = 200 raise ForbiddenAction if forbidden_actions.include? @action ccall end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
14 15 16 |
# File 'lib/ki/model.rb', line 14 def action @action end |
#params ⇒ Object
Returns the value of attribute params.
14 15 16 |
# File 'lib/ki/model.rb', line 14 def params @params end |
#req ⇒ Object
Returns the value of attribute req.
14 15 16 |
# File 'lib/ki/model.rb', line 14 def req @req end |
#result ⇒ Object
Returns the value of attribute result.
14 15 16 |
# File 'lib/ki/model.rb', line 14 def result @result end |
#status ⇒ Object
Returns the value of attribute status.
14 15 16 |
# File 'lib/ki/model.rb', line 14 def status @status end |
Instance Method Details
#create ⇒ Object
31 32 33 34 35 |
# File 'lib/ki/model.rb', line 31 def create check_for_required_attributes check_for_unique_attributes @result = self.class.create @params end |
#delete ⇒ Object
43 44 45 |
# File 'lib/ki/model.rb', line 43 def delete @result = self.class.delete @params end |
#find ⇒ Object
27 28 29 |
# File 'lib/ki/model.rb', line 27 def find @result = self.class.find @params end |
#update ⇒ Object
37 38 39 40 41 |
# File 'lib/ki/model.rb', line 37 def update check_for_required_attributes check_for_unique_attributes @result = self.class.update @params end |