Class: RenderAPI::DataObject
- Inherits:
-
Object
- Object
- RenderAPI::DataObject
- Defined in:
- lib/render_api/data_object.rb
Constant Summary collapse
- TIME_PATTERN =
/\A\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d.\d+Z\z/.freeze
Instance Attribute Summary collapse
-
#cursor ⇒ Object
readonly
Returns the value of attribute cursor.
Instance Method Summary collapse
-
#initialize(data) ⇒ DataObject
constructor
A new instance of DataObject.
- #to_h ⇒ Object
Constructor Details
#initialize(data) ⇒ DataObject
Returns a new instance of DataObject.
11 12 13 14 15 16 17 18 |
# File 'lib/render_api/data_object.rb', line 11 def initialize(data) if data["cursor"] @cursor = data.delete("cursor") @data = data.values.first else @data = data end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, **kwargs, &block) ⇒ Object (private)
28 29 30 31 32 33 |
# File 'lib/render_api/data_object.rb', line 28 def method_missing(name, *args, **kwargs, &block) return super unless respond_to_missing?(name, false) raise ArgumentError if args.any? || kwargs.any? || block translate(data[Camelise.call(name.to_s)]) end |
Instance Attribute Details
#cursor ⇒ Object (readonly)
Returns the value of attribute cursor.
9 10 11 |
# File 'lib/render_api/data_object.rb', line 9 def cursor @cursor end |
Instance Method Details
#to_h ⇒ Object
20 21 22 |
# File 'lib/render_api/data_object.rb', line 20 def to_h data end |