Module: Eapi::Methods::Properties::InstanceMethods
- Defined in:
- lib/eapi/methods/properties.rb
Instance Method Summary collapse
- #_properties ⇒ Object
- #convert_value(value, convert_with = nil) ⇒ Object
- #converted_or_default_value_for(property) ⇒ Object
- #converted_value_for(prop) ⇒ Object
- #final_value_for(property) ⇒ Object
- #get(field) ⇒ Object
- #prepare_value_for(prop) ⇒ Object
- #set(field, value) ⇒ Object
- #to_be_ignored?(value, property) ⇒ Boolean
-
#yield_final_value_for(property) ⇒ Object
will yield the converted value if it is not to be ignored, will yield the default value if it is set and the converted value is to be ignored will not yield anything otherwise.
Instance Method Details
#_properties ⇒ Object
7 8 9 |
# File 'lib/eapi/methods/properties.rb', line 7 def _properties self.class.properties end |
#convert_value(value, convert_with = nil) ⇒ Object
36 37 38 |
# File 'lib/eapi/methods/properties.rb', line 36 def convert_value(value, convert_with = nil) Eapi::ValueConverter.convert_value(value, self, convert_with) end |
#converted_or_default_value_for(property) ⇒ Object
40 41 42 |
# File 'lib/eapi/methods/properties.rb', line 40 def converted_or_default_value_for(property) yield_final_value_for(property) { |val| return val } end |
#converted_value_for(prop) ⇒ Object
32 33 34 |
# File 'lib/eapi/methods/properties.rb', line 32 def converted_value_for(prop) convert_value get(prop), self.class.defined_convert_with_for(prop) end |
#final_value_for(property) ⇒ Object
44 45 46 |
# File 'lib/eapi/methods/properties.rb', line 44 def final_value_for(property) converted_or_default_value_for(property) end |
#get(field) ⇒ Object
11 12 13 14 |
# File 'lib/eapi/methods/properties.rb', line 11 def get(field) getter = Eapi::Methods::Names.getter field send(getter) end |
#prepare_value_for(prop) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/eapi/methods/properties.rb', line 21 def prepare_value_for(prop) value = get(prop) prepare_with = self.class.defined_prepare_with_for(prop) if prepare_with convert_value(value, prepare_with) else value end end |
#set(field, value) ⇒ Object
16 17 18 19 |
# File 'lib/eapi/methods/properties.rb', line 16 def set(field, value) setter = Eapi::Methods::Names.fluent_setter field send(setter, value) end |
#to_be_ignored?(value, property) ⇒ Boolean
62 63 64 |
# File 'lib/eapi/methods/properties.rb', line 62 def to_be_ignored?(value, property) Eapi::ValueIgnoreChecker.to_be_ignored? value, self.class.ignore_definition(property) end |
#yield_final_value_for(property) ⇒ Object
will yield the converted value if it is not to be ignored, will yield the default value if it is set and the converted value is to be ignored will not yield anything otherwise
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/eapi/methods/properties.rb', line 51 def yield_final_value_for(property) val = converted_value_for(property) accepted = !to_be_ignored?(val, property) if accepted yield val elsif self.class.default_value_for?(property) yield self.class.default_value_for(property) end end |