Class: Trophonius::RecordSet
- Inherits:
-
Array
- Object
- Array
- Trophonius::RecordSet
- Defined in:
- lib/trophonius_recordset.rb
Overview
A RecordSet contains all records, as Record, retrieved from the FileMaker database
Defined Under Namespace
Classes: EmptyParameterError
Instance Attribute Summary collapse
-
#layout_name ⇒ Object
Returns the value of attribute layout_name.
-
#non_modifiable_fields ⇒ Object
Returns the value of attribute non_modifiable_fields.
-
#records ⇒ Object
Returns the value of attribute records.
-
#result_count ⇒ Object
Returns the value of attribute result_count.
Instance Method Summary collapse
- #<<(data) ⇒ Object
-
#initialize(l_name, nmf) ⇒ RecordSet
constructor
Initializes a new RecordSet.
-
#paginate(page, records_per_page) ⇒ RecordSet
This method chops the RecordSet up in parts.
-
#where(fielddata) ⇒ RecordSet
This method allows to chain where statements.
Constructor Details
#initialize(l_name, nmf) ⇒ RecordSet
Initializes a new RecordSet
19 20 21 22 23 |
# 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 |
Instance Attribute Details
#layout_name ⇒ Object
Returns the value of attribute layout_name.
9 10 11 |
# File 'lib/trophonius_recordset.rb', line 9 def layout_name @layout_name end |
#non_modifiable_fields ⇒ Object
Returns the value of attribute non_modifiable_fields.
9 10 11 |
# File 'lib/trophonius_recordset.rb', line 9 def non_modifiable_fields @non_modifiable_fields end |
#records ⇒ Object
Returns the value of attribute records.
9 10 11 |
# File 'lib/trophonius_recordset.rb', line 9 def records @records end |
#result_count ⇒ Object
Returns the value of attribute result_count.
9 10 11 |
# File 'lib/trophonius_recordset.rb', line 9 def result_count @result_count end |
Instance Method Details
#<<(data) ⇒ Object
25 26 27 28 |
# File 'lib/trophonius_recordset.rb', line 25 def <<(data) records << data super end |
#paginate(page, records_per_page) ⇒ RecordSet
This method chops the RecordSet up in parts.
53 54 55 56 |
# 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) ⇒ RecordSet
This method allows to chain where statements
36 37 38 39 40 41 42 43 |
# 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 |