Class: FluentQuery::Data
- Inherits:
-
Object
- Object
- FluentQuery::Data
- Defined in:
- lib/fluent-query/data.rb
Overview
Represents data hash.
In fact, it’s common Hash class extended by method which allow access its fields by “object way”.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Maps array access to underlying data object.
-
#initialize(data) ⇒ Data
constructor
Constructor.
-
#method_missing(name, *args) ⇒ Object
Maps missing calls to data elements.
-
#to_hash ⇒ Object
Converts data to hash.
Constructor Details
#initialize(data) ⇒ Data
Constructor.
24 25 26 |
# File 'lib/fluent-query/data.rb', line 24 def initialize(data) @data = data end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
Maps missing calls to data elements.
32 33 34 |
# File 'lib/fluent-query/data.rb', line 32 def method_missing(name, *args) @data[name] end |
Instance Method Details
#[](key) ⇒ Object
Maps array access to underlying data object.
40 41 42 |
# File 'lib/fluent-query/data.rb', line 40 def [](key) @data[key.to_sym] end |
#to_hash ⇒ Object
Converts data to hash.
48 49 50 |
# File 'lib/fluent-query/data.rb', line 48 def to_hash @data.to_hash.dup end |