Class: Ki::Model
- Inherits:
-
Object
- Object
- Ki::Model
- Extended by:
- QueryInterface, Restrictions
- Includes:
- 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.
-
#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(action, params) ⇒ 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 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(action, params) ⇒ Model
Returns a new instance of Model.
10 11 12 13 14 15 16 17 18 |
# File 'lib/ki/model.rb', line 10 def initialize(action, params) @action = action @params = params @status = 200 fail ForbiddenAction if forbidden_actions.include? @action ccall end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
8 9 10 |
# File 'lib/ki/model.rb', line 8 def action @action end |
#params ⇒ Object
Returns the value of attribute params.
8 9 10 |
# File 'lib/ki/model.rb', line 8 def params @params end |
#result ⇒ Object
Returns the value of attribute result.
8 9 10 |
# File 'lib/ki/model.rb', line 8 def result @result end |
#status ⇒ Object
Returns the value of attribute status.
8 9 10 |
# File 'lib/ki/model.rb', line 8 def status @status end |
Instance Method Details
#create ⇒ Object
24 25 26 27 28 |
# File 'lib/ki/model.rb', line 24 def create check_for_required_attributes check_for_unique_attributes @result = self.class.create @params end |
#delete ⇒ Object
36 37 38 |
# File 'lib/ki/model.rb', line 36 def delete @result = self.class.delete @params end |
#find ⇒ Object
20 21 22 |
# File 'lib/ki/model.rb', line 20 def find @result = self.class.find @params end |
#update ⇒ Object
30 31 32 33 34 |
# File 'lib/ki/model.rb', line 30 def update check_for_required_attributes check_for_unique_attributes @result = self.class.update @params end |