Class: RenderAPI::DataObject

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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)

Raises:

  • (ArgumentError)


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

#cursorObject (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_hObject



20
21
22
# File 'lib/render_api/data_object.rb', line 20

def to_h
  data
end