Class: Lorj::BaseController
- Defined in:
- lib/core/lorj_basecontroller.rb,
lib/core/lorj_basecontroller.rb
Overview
Defining private internal controller functions
Instance Method Summary collapse
-
#connect(_sObjectType, _hParams) ⇒ Object
Default handlers which needs to be defined by the controller, called by BaseDefinition Create functions.
-
#controller_error(msg, *p) ⇒ Object
Simply raise an error.
-
#create(_sObjectType, _hParams) ⇒ Object
Default handlers which needs to be defined by the controller, called by BaseDefinition Create functions.
-
#delete(_sObjectType, _hParams) ⇒ Object
Default handlers which needs to be defined by the controller, called by BaseDefinition Delete functions.
-
#get(_sObjectType, _sUniqId, _hParams) ⇒ Object
Default handlers which needs to be defined by the controller, called by BaseDefinition Get functions.
-
#query(_sObjectType, _sQuery, _hParams) ⇒ Object
Default handlers which needs to be defined by the controller, called by BaseDefinition Query functions.
-
#refresh(_sObjectType, _oObject) ⇒ Object
controller refresh handlers which needs to be defined by the controller, this function should execute a controller data refresh.
-
#required?(oParams, *key) ⇒ Boolean
check if required data is loaded.
-
#update(_sObjectType, _oObject, _hParams) ⇒ Object
Default handlers which needs to be defined by the controller, called by BaseDefinition Update functions.
Instance Method Details
#connect(_sObjectType, _hParams) ⇒ Object
Default handlers which needs to be defined by the controller, called by BaseDefinition Create functions.
33 34 35 |
# File 'lib/core/lorj_basecontroller.rb', line 33 def connect(_sObjectType, _hParams) controller_error 'connect has not been redefined by the controller.' end |
#controller_error(msg, *p) ⇒ Object
Simply raise an error
-
Args :
-
Msg
: Error message to print out.
-
-
Returns :
-
nil
-
-
Raises :
-
Lorj::PrcError
96 97 98 99 |
# File 'lib/core/lorj_basecontroller.rb', line 96 def controller_error(msg, *p) msg = format(msg, *p) fail Lorj::PrcError.new, format('%s: %s', self.class, msg) end |
#create(_sObjectType, _hParams) ⇒ Object
Default handlers which needs to be defined by the controller, called by BaseDefinition Create functions.
39 40 41 |
# File 'lib/core/lorj_basecontroller.rb', line 39 def create(_sObjectType, _hParams) controller_error 'create_object has not been redefined by the controller.' end |
#delete(_sObjectType, _hParams) ⇒ Object
Default handlers which needs to be defined by the controller, called by BaseDefinition Delete functions.
45 46 47 |
# File 'lib/core/lorj_basecontroller.rb', line 45 def delete(_sObjectType, _hParams) controller_error 'delete_object has not been redefined by the controller.' end |
#get(_sObjectType, _sUniqId, _hParams) ⇒ Object
Default handlers which needs to be defined by the controller, called by BaseDefinition Get functions.
51 52 53 |
# File 'lib/core/lorj_basecontroller.rb', line 51 def get(_sObjectType, _sUniqId, _hParams) controller_error 'get_object has not been redefined by the controller.' end |
#query(_sObjectType, _sQuery, _hParams) ⇒ Object
Default handlers which needs to be defined by the controller, called by BaseDefinition Query functions.
57 58 59 |
# File 'lib/core/lorj_basecontroller.rb', line 57 def query(_sObjectType, _sQuery, _hParams) controller_error 'query_object has not been redefined by the controller.' end |
#refresh(_sObjectType, _oObject) ⇒ Object
controller refresh handlers which needs to be defined by the controller, this function should execute a controller data refresh
The controller must respect the following rule:
-
If the refresh was unsuccessful, due to errors, the original object should be kept intact.
-
A boolean should be return to inform that therefresh was executed successfully or not.
-
parameters:
-
object_type
: Lorj object type to use for the refresh. -
object
: object to refresh.
-
-
returns:
-
boolean: true if refresh was executed successfully. false otherwise.
-
84 85 86 |
# File 'lib/core/lorj_basecontroller.rb', line 84 def refresh(_sObjectType, _oObject) controller_error 'refresh_object has not been redefined by the controller' end |
#required?(oParams, *key) ⇒ Boolean
check if required data is loaded. raise an error if not
-
Args :
-
Params
: Lorj::ObjectData object for controller. -
key
: Key to check.
-
-
Returns :
-
nil
-
-
Raises :
-
Error
if the key do not exist.
-
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/core/lorj_basecontroller.rb', line 110 def required?(oParams, *key) if oParams.exist?(key) if RUBY_VERSION =~ /1\.8/ # debugger # rubocop: disable Lint/Debugger if oParams.otype?(*key) == :DataObject && oParams[key, :ObjectData].empty? controller_error '%s is empty.', key end else if oParams.type?(*key) == :DataObject && oParams[key, :ObjectData].empty? controller_error '%s is empty.', key end end return end controller_error '%s is not set.', key end |
#update(_sObjectType, _oObject, _hParams) ⇒ Object
Default handlers which needs to be defined by the controller, called by BaseDefinition Update functions.
63 64 65 |
# File 'lib/core/lorj_basecontroller.rb', line 63 def update(_sObjectType, _oObject, _hParams) controller_error 'update_object has not been redefined by the controller.' end |