Class: Rfm::Resultset
- Includes:
- Config
- Defined in:
- lib/rfm/resultset.rb
Overview
The ResultSet object represents a set of records in FileMaker. It is, in every way, a real Ruby Array, so everything you expect to be able to do with an Array can be done with a ResultSet as well. In this case, the elements in the array are Record objects.
Here’s a typical example, displaying the results of a Find:
myServer = Rfm::Server.new(...)
results = myServer["Customers"]["Details"].find("First Name" => "Bill")
results.each {|record|
puts record["First Name"]
puts record["Last Name"]
puts record["Email Address"]
}
Attributes
The ResultSet object has these attributes:
-
field_meta is a hash with field names for keys and Field objects for values; it provides info about the fields in the ResultSet
-
portal_meta is a hash with table occurrence names for keys and arrays of Field objects for values; it provides metadata about the portals in the ResultSet and the Fields on those portals
Constant Summary
Constants included from Config
Config::CONFIG_DONT_STORE, Config::CONFIG_KEYS
Instance Attribute Summary collapse
-
#calling_object ⇒ Object
readonly
Returns the value of attribute calling_object.
-
#layout ⇒ Object
readonly
This method was added for situations where a layout was not provided at resultset instantiation, such as when loading a resultset from an xml file.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
Class Method Summary collapse
Instance Method Summary collapse
-
#config(*args) ⇒ Object
initialize.
- #database ⇒ Object (also: #db)
- #end_datasource_element_callback(cursor) ⇒ Object
-
#handle_new_record(attributes) ⇒ Object
Deprecated on 7/29/2014.
-
#initialize(*args) ⇒ Resultset
constructor
Initializes a new ResultSet object.
- #server ⇒ Object
Methods included from Config
#config_clear, #get_config, #log, #state
Methods inherited from Array
#_merge_object!, #rfm_extend_member, #rfm_extend_members, #rfm_extract_options!
Constructor Details
#initialize(*args) ⇒ Resultset
Initializes a new ResultSet object. You will probably never do this your self (instead, use the Layout object to get various ResultSet obejects).
If you feel so inclined, though, pass a Server object, and some fmpxmlresult
compliant XML in a String.
Attributes
The ResultSet object includes several useful attributes:
-
fields is a hash (with field names for keys and Field objects for values). It includes an entry for every field in the ResultSet. Note: You don’t use Field objects to access data. If you’re after data, get a Record object (ResultSet is an array of records). Field objects tell you about the fields (their type, repetitions, and so forth) in case you find that information useful programmatically.
Note: keys in the
fields
hash are downcased for convenience (and [] automatically downcases on lookup, so it should be seamless). But if youeach
a field hash and need to know a field’s real name, with correct case, domyField.name
instead of relying on the key in the hash. -
portals is a hash (with table occurrence names for keys and Field objects for values). If your layout contains portals, you can find out what fields they contain here. Again, if it’s the data you’re after, you want to look at the Record object.
77 78 79 80 |
# File 'lib/rfm/resultset.rb', line 77 def initialize(*args) # parent, layout config(*args) self. end |
Instance Attribute Details
#calling_object ⇒ Object (readonly)
Returns the value of attribute calling_object.
41 42 43 |
# File 'lib/rfm/resultset.rb', line 41 def calling_object @calling_object end |
#layout ⇒ Object (readonly)
This method was added for situations where a layout was not provided at resultset instantiation, such as when loading a resultset from an xml file.
93 94 95 |
# File 'lib/rfm/resultset.rb', line 93 def layout @layout end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
41 42 43 |
# File 'lib/rfm/resultset.rb', line 41 def @meta end |
Class Method Details
Instance Method Details
#config(*args) ⇒ Object
initialize
82 83 84 85 86 87 88 89 |
# File 'lib/rfm/resultset.rb', line 82 def config(*args) super do |params| (@layout = params[:objects][0]) if params && params[:objects] && params[:objects][0] && params[:objects][0].is_a?(Rfm::Layout) end end |
#database ⇒ Object Also known as: db
97 98 99 |
# File 'lib/rfm/resultset.rb', line 97 def database layout.database end |
#end_datasource_element_callback(cursor) ⇒ Object
119 120 121 122 |
# File 'lib/rfm/resultset.rb', line 119 def end_datasource_element_callback(cursor) %w(date_format time_format timestamp_format).each{|f| convert_date_time_format(send(f))} @meta.attach_layout_object_from_cursor(cursor) end |
#handle_new_record(attributes) ⇒ Object
Deprecated on 7/29/2014. Stop using.
113 114 115 116 117 |
# File 'lib/rfm/resultset.rb', line 113 def handle_new_record(attributes) r = Rfm::Record.new(self, attributes, {}) self << r r end |
#server ⇒ Object
103 104 105 |
# File 'lib/rfm/resultset.rb', line 103 def server database.server end |