Class: Dillo::Rows
Instance Attribute Summary
Attributes inherited from Base
#connection
Instance Method Summary
collapse
Methods inherited from Collection
#each, #records
Methods included from Finders
#[], #method_missing, #respond_to?
Methods inherited from Base
#body, #inspect, #json, #prepare_request, root
Constructor Details
#initialize(id) ⇒ Rows
Returns a new instance of Rows.
243
244
245
246
|
# File 'lib/dillo.rb', line 243
def initialize(id)
@id = id
super()
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Dillo::Finders
Instance Method Details
#column_index(name) ⇒ Object
264
265
266
|
# File 'lib/dillo.rb', line 264
def column_index(name)
columns.index(name.to_s.downcase)
end
|
#columns ⇒ Object
260
261
262
|
# File 'lib/dillo.rb', line 260
def columns
@columns ||= json['meta']['view']['columns'].map { |column| column['name'].downcase }
end
|
#create_record(attributes) ⇒ Object
268
269
270
|
# File 'lib/dillo.rb', line 268
def create_record(attributes)
record_class.new(self, attributes)
end
|
#path ⇒ Object
248
249
250
|
# File 'lib/dillo.rb', line 248
def path
"/api/views/#{@id}/rows.json"
end
|
#record_attributes ⇒ Object
256
257
258
|
# File 'lib/dillo.rb', line 256
def record_attributes
json['data']
end
|
#record_class ⇒ Object
252
253
254
|
# File 'lib/dillo.rb', line 252
def record_class
Row
end
|