Class: Avm::Instances::Entry
Class Method Summary collapse
Instance Method Summary collapse
- #auto_value ⇒ Object
- #auto_value_method ⇒ Object
- #full_path ⇒ Object
- #optional_value ⇒ Object
- #read(extra_options = {}) ⇒ Object
- #suffix_as_array ⇒ Object
- #value ⇒ Object
- #write(value) ⇒ Object
Class Method Details
.auto_value_method_name(suffix) ⇒ Object
10 11 12 |
# File 'lib/avm/instances/entry.rb', line 10 def auto_value_method_name(suffix) "auto_#{suffix.to_s.gsub('.', '_')}" end |
Instance Method Details
#auto_value ⇒ Object
17 18 19 |
# File 'lib/avm/instances/entry.rb', line 17 def auto_value parent.respond_to?(auto_value_method, true) ? parent.send(auto_value_method) : nil end |
#auto_value_method ⇒ Object
21 22 23 |
# File 'lib/avm/instances/entry.rb', line 21 def auto_value_method self.class.auto_value_method_name(suffix) end |
#full_path ⇒ Object
25 26 27 |
# File 'lib/avm/instances/entry.rb', line 25 def full_path (parent.path_prefix + suffix_as_array).join('.') end |
#optional_value ⇒ Object
29 30 31 |
# File 'lib/avm/instances/entry.rb', line 29 def optional_value read(required: false, noinput: true) || auto_value end |
#read(extra_options = {}) ⇒ Object
33 34 35 |
# File 'lib/avm/instances/entry.rb', line 33 def read( = {}) ::Avm::Apps::Config.current.entry(full_path, .merge()).value end |
#suffix_as_array ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/avm/instances/entry.rb', line 37 def suffix_as_array if suffix.is_a?(::Array) suffix.dup else ::EacConfig::PathsHash.parse_entry_key(suffix.to_s) end end |
#value ⇒ Object
45 46 47 |
# File 'lib/avm/instances/entry.rb', line 45 def value optional_value || read end |