Module: FmStore::Criterion::Optional

Included in:
FmStore::Criteria
Defined in:
lib/fm_store/criterion/optional.rb

Instance Method Summary collapse

Instance Method Details

#limit(value = 20) ⇒ Object



12
13
14
15
# File 'lib/fm_store/criterion/optional.rb', line 12

def limit(value = 20)
  @options[:max_records] = value
  self
end

#order(field_and_orders) ⇒ Object

ascend or descend



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/fm_store/criterion/optional.rb', line 18

def order(field_and_orders)
  sorts = field_and_orders.split(",").map(&:strip)
  sort_field = []
  sort_order = []
  
  sorts.each do |s|
    field, order = s.split(" ")
    order = "asc" unless order
    
    fm_name = klass.find_fm_name(field)
    
    order = "ascend" if order.downcase == "asc"
    order = "descend" if order.downcase == "desc"
    
    sort_field << fm_name
    sort_order << order
  end
  
  @options[:sort_field] = sort_field
  @options[:sort_order] = sort_order
  
  self
end

#skip(value = 20) ⇒ Object

Tell FileMaker how many records in the found set to skip. Use together with limit to page through the records



7
8
9
10
# File 'lib/fm_store/criterion/optional.rb', line 7

def skip(value = 20)
  @options[:skip_records] = value
  self
end