Class: Journea::Data
- Inherits:
-
Object
- Object
- Journea::Data
- Defined in:
- lib/journea/data.rb
Instance Attribute Summary collapse
-
#keyvalues ⇒ Object
readonly
Returns the value of attribute keyvalues.
Instance Method Summary collapse
-
#initialize(keyvalue_collection) ⇒ Data
constructor
A new instance of Data.
-
#method_missing(method_sym, *arguments, &block) ⇒ Object
TODO: Currently having to eat this rubocop error until such time as we understand what form the respond_to_missing? should take rubocop:disable Style/MethodMissing.
Constructor Details
#initialize(keyvalue_collection) ⇒ Data
Returns a new instance of Data.
6 7 8 |
# File 'lib/journea/data.rb', line 6 def initialize(keyvalue_collection) @keyvalues = keyvalue_collection end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym, *arguments, &block) ⇒ Object
TODO: Currently having to eat this rubocop error until such time as we understand what form the respond_to_missing? should take rubocop:disable Style/MethodMissing
13 14 15 16 17 |
# File 'lib/journea/data.rb', line 13 def method_missing(method_sym, *arguments, &block) val = keyvalues.find_by(key: method_sym).value return val if val.present? super end |
Instance Attribute Details
#keyvalues ⇒ Object (readonly)
Returns the value of attribute keyvalues.
4 5 6 |
# File 'lib/journea/data.rb', line 4 def keyvalues @keyvalues end |