Class: Windy::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.
242
243
244
245
|
# File 'lib/windy.rb', line 242
def initialize(id)
@id = id
super()
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Windy::Finders
Instance Method Details
#column_index(name) ⇒ Object
263
264
265
|
# File 'lib/windy.rb', line 263
def column_index(name)
columns.index(name.to_s.downcase)
end
|
#columns ⇒ Object
259
260
261
|
# File 'lib/windy.rb', line 259
def columns
@columns ||= json['meta']['view']['columns'].map { |column| column['name'].downcase }
end
|
#create_record(attributes) ⇒ Object
267
268
269
|
# File 'lib/windy.rb', line 267
def create_record(attributes)
record_class.new(self, attributes)
end
|
#path ⇒ Object
247
248
249
|
# File 'lib/windy.rb', line 247
def path
"/api/views/#{@id}/rows.json"
end
|
#record_attributes ⇒ Object
255
256
257
|
# File 'lib/windy.rb', line 255
def record_attributes
json['data']
end
|
#record_class ⇒ Object
251
252
253
|
# File 'lib/windy.rb', line 251
def record_class
Row
end
|