Module: ActiveFedora::QueryMethods
- Included in:
- Relation
- Defined in:
- lib/active_fedora/relation/query_methods.rb
Overview
:nodoc:
Instance Method Summary collapse
- #build_where(values) ⇒ Object
-
#extending!(*modules, &block) ⇒ Object
:nodoc:.
- #extending_values ⇒ Object
- #extending_values=(values) ⇒ Object
-
#limit(value) ⇒ Object
Limits the number of returned records to the value specified.
- #limit!(value) ⇒ Object
- #limit_value ⇒ Object
- #limit_value=(value) ⇒ Object
-
#none! ⇒ Object
:nodoc:.
-
#order(*args) ⇒ Object
Order the returned records by the field and direction provided.
- #order!(*args) ⇒ Object
- #order_values ⇒ Object
- #order_values=(values) ⇒ Object
- #select ⇒ Object
-
#where(values) ⇒ Object
Limits the returned records to those that match the provided search conditions.
- #where!(values) ⇒ Object
- #where_values ⇒ Object
- #where_values=(values) ⇒ Object
Instance Method Details
#build_where(values) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/active_fedora/relation/query_methods.rb', line 56 def build_where(values) return [] if values.blank? case values when Hash [create_query_from_hash(values)] when String ["(#{values})"] else [values] end end |
#extending!(*modules, &block) ⇒ Object
:nodoc:
104 105 106 107 108 109 110 111 112 |
# File 'lib/active_fedora/relation/query_methods.rb', line 104 def extending!(*modules, &block) # :nodoc: modules << Module.new(&block) if block modules.flatten! self.extending_values += modules extend(*extending_values) if extending_values.any? self end |
#extending_values ⇒ Object
4 5 6 |
# File 'lib/active_fedora/relation/query_methods.rb', line 4 def extending_values @values[:extending] || [] end |
#extending_values=(values) ⇒ Object
8 9 10 11 |
# File 'lib/active_fedora/relation/query_methods.rb', line 8 def extending_values=(values) raise ImmutableRelation if @loaded @values[:extending] = values end |
#limit(value) ⇒ Object
Limits the number of returned records to the value specified
91 92 93 |
# File 'lib/active_fedora/relation/query_methods.rb', line 91 def limit(value) spawn.limit!(value) end |
#limit!(value) ⇒ Object
95 96 97 98 |
# File 'lib/active_fedora/relation/query_methods.rb', line 95 def limit!(value) self.limit_value = value self end |
#limit_value ⇒ Object
31 32 33 |
# File 'lib/active_fedora/relation/query_methods.rb', line 31 def limit_value @values[:limit] end |
#limit_value=(value) ⇒ Object
35 36 37 38 |
# File 'lib/active_fedora/relation/query_methods.rb', line 35 def limit_value=(value) raise ImmutableRelation if @loaded @values[:limit] = value end |
#none! ⇒ Object
:nodoc:
100 101 102 |
# File 'lib/active_fedora/relation/query_methods.rb', line 100 def none! # :nodoc: extending!(NullRelation) end |
#order(*args) ⇒ Object
Order the returned records by the field and direction provided
75 76 77 |
# File 'lib/active_fedora/relation/query_methods.rb', line 75 def order(*args) spawn.order!(args) end |
#order!(*args) ⇒ Object
79 80 81 82 |
# File 'lib/active_fedora/relation/query_methods.rb', line 79 def order!(*args) self.order_values += args.flatten self end |
#order_values ⇒ Object
22 23 24 |
# File 'lib/active_fedora/relation/query_methods.rb', line 22 def order_values @values[:order] || [] end |
#order_values=(values) ⇒ Object
26 27 28 29 |
# File 'lib/active_fedora/relation/query_methods.rb', line 26 def order_values=(values) raise ImmutableRelation if @loaded @values[:order] = values end |
#select ⇒ Object
114 115 116 |
# File 'lib/active_fedora/relation/query_methods.rb', line 114 def select to_a.select { |*block_args| yield(*block_args) } end |
#where(values) ⇒ Object
Limits the returned records to those that match the provided search conditions
47 48 49 |
# File 'lib/active_fedora/relation/query_methods.rb', line 47 def where(values) spawn.where!(values) end |
#where!(values) ⇒ Object
51 52 53 54 |
# File 'lib/active_fedora/relation/query_methods.rb', line 51 def where!(values) self.where_values += build_where(values) self end |
#where_values ⇒ Object
13 14 15 |
# File 'lib/active_fedora/relation/query_methods.rb', line 13 def where_values @values[:where] ||= [] end |
#where_values=(values) ⇒ Object
17 18 19 20 |
# File 'lib/active_fedora/relation/query_methods.rb', line 17 def where_values=(values) raise ImmutableRelation if @loaded @values[:where] = values end |