Class: Journea::Data

Inherits:
Object
  • Object
show all
Defined in:
lib/journea/data.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#keyvaluesObject (readonly)

Returns the value of attribute keyvalues.



4
5
6
# File 'lib/journea/data.rb', line 4

def keyvalues
  @keyvalues
end