Class: FmStore::Criteria
- Inherits:
-
Object
- Object
- FmStore::Criteria
- Includes:
- Enumerable, FmStore::Criterion::Exclusion, FmStore::Criterion::Inclusion, FmStore::Criterion::Optional
- Defined in:
- lib/fm_store/criteria.rb
Instance Attribute Summary collapse
-
#find_query ⇒ Object
Returns the value of attribute find_query.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#raw_params ⇒ Object
readonly
Returns the value of attribute raw_params.
Instance Method Summary collapse
- #all ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(klass, find_query = false) ⇒ Criteria
constructor
A new instance of Criteria.
- #reader ⇒ Object
- #to_s ⇒ Object
- #total ⇒ Object
Methods included from FmStore::Criterion::Optional
Methods included from FmStore::Criterion::Exclusion
Methods included from FmStore::Criterion::Inclusion
#custom_query, #fm_id, #id, #in, #search, #where
Constructor Details
#initialize(klass, find_query = false) ⇒ Criteria
Returns a new instance of Criteria.
54 55 56 57 58 59 60 61 62 |
# File 'lib/fm_store/criteria.rb', line 54 def initialize(klass, find_query = false) @params, @options, @klass, @find_query = {}, {}, klass, find_query if find_query @key_values = {} @query_map = [] @counter = 0 end end |
Instance Attribute Details
#find_query ⇒ Object
Returns the value of attribute find_query.
50 51 52 |
# File 'lib/fm_store/criteria.rb', line 50 def find_query @find_query end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
49 50 51 |
# File 'lib/fm_store/criteria.rb', line 49 def klass @klass end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
49 50 51 |
# File 'lib/fm_store/criteria.rb', line 49 def @options end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
49 50 51 |
# File 'lib/fm_store/criteria.rb', line 49 def params @params end |
#raw_params ⇒ Object (readonly)
Returns the value of attribute raw_params.
49 50 51 |
# File 'lib/fm_store/criteria.rb', line 49 def raw_params @raw_params end |
Instance Method Details
#all ⇒ Object
84 85 86 |
# File 'lib/fm_store/criteria.rb', line 84 def all reader.execute end |
#each(&block) ⇒ Object
68 69 70 |
# File 'lib/fm_store/criteria.rb', line 68 def each(&block) reader.execute.each { |record| yield record } if block_given? end |
#reader ⇒ Object
64 65 66 |
# File 'lib/fm_store/criteria.rb', line 64 def reader @reader ||= FmReader.new(self) end |
#to_s ⇒ Object
72 73 74 |
# File 'lib/fm_store/criteria.rb', line 72 def to_s "#{params.inspect}, #{.inspect}" end |
#total ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/fm_store/criteria.rb', line 76 def total original_max_record = [:max_records] count = paginate(:per_page => 1).total_entries limit(original_max_record) return count end |