Class: Friendly::Query
- Inherits:
-
Object
- Object
- Friendly::Query
- Defined in:
- lib/friendly/query.rb
Instance Attribute Summary collapse
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#per_page ⇒ Object
readonly
Returns the value of attribute per_page.
-
#preserve_order ⇒ Object
readonly
Returns the value of attribute preserve_order.
-
#uuid_klass ⇒ Object
readonly
Returns the value of attribute uuid_klass.
Instance Method Summary collapse
-
#initialize(parameters, uuid_klass = UUID) ⇒ Query
constructor
A new instance of Query.
- #offset? ⇒ Boolean
- #preserve_order? ⇒ Boolean
Constructor Details
#initialize(parameters, uuid_klass = UUID) ⇒ Query
Returns a new instance of Query.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/friendly/query.rb', line 7 def initialize(parameters, uuid_klass = UUID) @uuid_klass = uuid_klass @conditions = parameters.reject { |k,v| k.to_s =~ /!$/ } @page = (parameters[:page!] || 1).to_i [:per_page!, :limit!, :offset!, :order!, :preserve_order!].each do |p| instance_variable_set("@#{p.to_s.gsub(/!/, '')}", parameters[p]) end handle_pagination if per_page convert_ids_to_uuids end |
Instance Attribute Details
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
3 4 5 |
# File 'lib/friendly/query.rb', line 3 def conditions @conditions end |
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
3 4 5 |
# File 'lib/friendly/query.rb', line 3 def limit @limit end |
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
3 4 5 |
# File 'lib/friendly/query.rb', line 3 def offset @offset end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
3 4 5 |
# File 'lib/friendly/query.rb', line 3 def order @order end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
3 4 5 |
# File 'lib/friendly/query.rb', line 3 def page @page end |
#per_page ⇒ Object (readonly)
Returns the value of attribute per_page.
3 4 5 |
# File 'lib/friendly/query.rb', line 3 def per_page @per_page end |
#preserve_order ⇒ Object (readonly)
Returns the value of attribute preserve_order.
3 4 5 |
# File 'lib/friendly/query.rb', line 3 def preserve_order @preserve_order end |
#uuid_klass ⇒ Object (readonly)
Returns the value of attribute uuid_klass.
3 4 5 |
# File 'lib/friendly/query.rb', line 3 def uuid_klass @uuid_klass end |