Module: Imperator::Command::RestHelper
- Extended by:
- ActiveSupport::Concern
- Included in:
- Rest, Mongoid::Command::Rest
- Defined in:
- lib/imperator/command/rest_helper.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #find_object ⇒ Object
- #find_object_error ⇒ Object
- #object_class ⇒ Object
- #on_error(exception) ⇒ Object
Instance Method Details
#find_object ⇒ Object
76 77 78 79 80 |
# File 'lib/imperator/command/rest_helper.rb', line 76 def find_object object ||= object_class.find(self.id) rescue find_object_error end |
#find_object_error ⇒ Object
82 83 84 |
# File 'lib/imperator/command/rest_helper.rb', line 82 def find_object_error raise Imperator::ResourceNotFoundError, "The resource #{self.id} could not be found" end |
#object_class ⇒ Object
68 69 70 |
# File 'lib/imperator/command/rest_helper.rb', line 68 def object_class self.class.object_class end |
#on_error(exception) ⇒ Object
72 73 74 |
# File 'lib/imperator/command/rest_helper.rb', line 72 def on_error exception raise Imperator::InvalidCommandError, "The Command #{self} caused an error: #{exception}" end |