Class: Labimotion::PropertiesHandler
- Inherits:
-
Object
- Object
- Labimotion::PropertiesHandler
- Defined in:
- lib/labimotion/libs/properties_handler.rb
Class Method Summary collapse
- .check_properties(properties) ⇒ Object
- .copy(properties, key, type) ⇒ Object
- .detach(properties, key, type) ⇒ Object
- .split(properties, key, type) ⇒ Object
Class Method Details
.check_properties(properties) ⇒ Object
50 51 52 |
# File 'lib/labimotion/libs/properties_handler.rb', line 50 def self.check_properties(properties) properties.nil? || !properties.is_a?(Hash) || properties[Labimotion::Prop::LAYERS].nil? || properties[Labimotion::Prop::LAYERS].keys.empty? end |
.copy(properties, key, type) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/labimotion/libs/properties_handler.rb', line 81 def self.copy(properties, key, type) fields = properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].select { |ss| ss['type'] == type } fields.each do |field| next unless check_val(field, type) idx = properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].index(field) ## TODO Copy Sample... end properties rescue StandardError => e Labimotion.log_exception(e) properties end |
.detach(properties, key, type) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/labimotion/libs/properties_handler.rb', line 54 def self.detach(properties, key, type) fields = properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].select { |ss| ss['type'] == type } fields.each do |field| next unless check_val(field, type) properties = detach_val(properties, field, key, type) end properties rescue StandardError => e Labimotion.log_exception(e) properties end |
.split(properties, key, type) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/labimotion/libs/properties_handler.rb', line 67 def self.split(properties, key, type) fields = properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].select { |ss| ss['type'] == type } fields.each do |field| next unless check_val(field, type) idx = properties[Labimotion::Prop::LAYERS][key][Labimotion::Prop::FIELDS].index(field) ## TODO Split ... end properties rescue StandardError => e Labimotion.log_exception(e) properties end |