Class: KalibroGatekeeperClient::Entities::ModuleResult
- Defined in:
- lib/kalibro_gatekeeper_client/entities/module_result.rb
Instance Attribute Summary collapse
-
#grade ⇒ Object
Returns the value of attribute grade.
-
#height ⇒ Object
Returns the value of attribute height.
-
#id ⇒ Object
Returns the value of attribute id.
-
#module ⇒ Object
Returns the value of attribute module.
-
#parent_id ⇒ Object
Returns the value of attribute parent_id.
Attributes inherited from Model
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Model
#==, create, create_array_from_hash, create_objects_array_from_hash, #destroy, exists?, #initialize, request, #save, #save!, #to_hash, to_object, to_objects_array
Methods included from RequestMethods::ClassMethods
#exists_action, #find_action, #id_params
Methods included from HashConverters
#convert_to_hash, #date_with_milliseconds, #field_to_hash
Methods included from XMLConverters
#get_xml, #xml_instance_class_name
Methods included from RequestMethods
#destroy_action, #destroy_params, #save_action, #save_params
Constructor Details
This class inherits a constructor from KalibroGatekeeperClient::Entities::Model
Instance Attribute Details
#grade ⇒ Object
Returns the value of attribute grade.
23 24 25 |
# File 'lib/kalibro_gatekeeper_client/entities/module_result.rb', line 23 def grade @grade end |
#height ⇒ Object
Returns the value of attribute height.
23 24 25 |
# File 'lib/kalibro_gatekeeper_client/entities/module_result.rb', line 23 def height @height end |
#id ⇒ Object
Returns the value of attribute id.
23 24 25 |
# File 'lib/kalibro_gatekeeper_client/entities/module_result.rb', line 23 def id @id end |
#module ⇒ Object
Returns the value of attribute module.
23 24 25 |
# File 'lib/kalibro_gatekeeper_client/entities/module_result.rb', line 23 def module @module end |
#parent_id ⇒ Object
Returns the value of attribute parent_id.
23 24 25 |
# File 'lib/kalibro_gatekeeper_client/entities/module_result.rb', line 23 def parent_id @parent_id end |
Class Method Details
.find(id) ⇒ Object
25 26 27 28 29 |
# File 'lib/kalibro_gatekeeper_client/entities/module_result.rb', line 25 def self.find(id) response = request('get', { id: id }) raise KalibroGatekeeperClient::Errors::RecordNotFound unless response['error'].nil? new response end |
.history_of(module_result_id) ⇒ Object
69 70 71 72 73 74 75 76 77 |
# File 'lib/kalibro_gatekeeper_client/entities/module_result.rb', line 69 def self.history_of(module_result_id) response = self.create_array_from_hash(self.request('history_of', {id: module_result_id})['date_module_results']) response.map do |date_module_result_pair| date_module_result = KalibroGatekeeperClient::Entities::DateModuleResult.new date_module_result.date = date_module_result_pair.first date_module_result.module_result = date_module_result_pair.last date_module_result end end |
Instance Method Details
#children ⇒ Object
31 32 33 34 |
# File 'lib/kalibro_gatekeeper_client/entities/module_result.rb', line 31 def children response = self.class.request('children_of', {id: id})['module_results'] self.class.create_objects_array_from_hash(response) end |
#file? ⇒ Boolean
65 66 67 |
# File 'lib/kalibro_gatekeeper_client/entities/module_result.rb', line 65 def file? !self.folder? end |
#folder? ⇒ Boolean
61 62 63 |
# File 'lib/kalibro_gatekeeper_client/entities/module_result.rb', line 61 def folder? self.children.count > 0 end |
#parents ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/kalibro_gatekeeper_client/entities/module_result.rb', line 36 def parents if parent_id == 0 [] else parent = self.class.find(parent_id) parent.parents << parent end end |