class Trophonius::RecordSet
A RecordSet
contains all records, as Record
, retrieved from the FileMaker database
Attributes
layout_name[RW]
non_modifiable_fields[RW]
records[RW]
result_count[RW]
Public Class Methods
new(l_name, nmf)
click to toggle source
Initializes a new RecordSet
@param [String] l_name: name of the FileMaker layout
@param [Array] nmf: names of the fields that cannot be modified (calculation fields etc.)
# File lib/trophonius_recordset.rb, line 19 def initialize(l_name, nmf) self.layout_name = l_name self.non_modifiable_fields = nmf self.records = [] end
Public Instance Methods
<<(data)
click to toggle source
Calls superclass method
# File lib/trophonius_recordset.rb, line 25 def <<(data) records << data super end
paginate(page, records_per_page)
click to toggle source
This method chops the RecordSet
up in parts.
@param [Integer] page: the current page
@param [Integer] records_per_page: the amount of records on the page
@return [RecordSet] the records in the range ((page * records_per_page) - records_per_page) + 1 until ((page * records_per_page) - records_per_page) + 1 + records_per_page
# File lib/trophonius_recordset.rb, line 53 def paginate(page, records_per_page) offset = ((page * records_per_page) - records_per_page) records[offset...offset + records_per_page] end
where(fielddata)
click to toggle source
This method allows to chain where statements
@param [Hash] fielddata: hash containing the query
@return [RecordSet] the records where the statement holds
# File lib/trophonius_recordset.rb, line 36 def where(fielddata) raise EmptyParameterError.new, 'No requested data to find' if fielddata.nil? || fielddata.empty? temp = Trophonius::Model temp.config layout_name: layout_name, non_modifiable_fields: non_modifiable_fields retval = temp.where(fielddata) retval end