Module: ActiveFedora::QueryMethods
- Included in:
- Relation
- Defined in:
- lib/active_fedora/relation/query_methods.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#build_where(values) ⇒ Array<String>
List of solr hashes.
-
#create_with_value ⇒ Object
:nodoc:.
-
#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:.
-
#offset(value) ⇒ Object
Start the returned records at an offset position.
- #offset!(value) ⇒ Object
- #offset_value ⇒ Object
- #offset_value=(value) ⇒ Object
-
#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) ⇒ Array<String>
Returns list of solr hashes.
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/active_fedora/relation/query_methods.rb', line 66 def build_where(values) return [] if values.blank? case values when Hash create_query_from_hash(values) when String ["(#{values})"] else [values] end end |
#create_with_value ⇒ Object
:nodoc:
145 146 147 |
# File 'lib/active_fedora/relation/query_methods.rb', line 145 def create_with_value # :nodoc: @values[:create_with] || {} end |
#extending!(*modules, &block) ⇒ Object
:nodoc:
131 132 133 134 135 136 137 138 139 |
# File 'lib/active_fedora/relation/query_methods.rb', line 131 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
3 4 5 |
# File 'lib/active_fedora/relation/query_methods.rb', line 3 def extending_values @values[:extending] || [] end |
#extending_values=(values) ⇒ Object
7 8 9 10 |
# File 'lib/active_fedora/relation/query_methods.rb', line 7 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
101 102 103 |
# File 'lib/active_fedora/relation/query_methods.rb', line 101 def limit(value) spawn.limit!(value) end |
#limit!(value) ⇒ Object
105 106 107 108 |
# File 'lib/active_fedora/relation/query_methods.rb', line 105 def limit!(value) self.limit_value = value self end |
#limit_value ⇒ Object
30 31 32 |
# File 'lib/active_fedora/relation/query_methods.rb', line 30 def limit_value @values[:limit] end |
#limit_value=(value) ⇒ Object
34 35 36 37 |
# File 'lib/active_fedora/relation/query_methods.rb', line 34 def limit_value=(value) raise ImmutableRelation if @loaded @values[:limit] = value end |
#none! ⇒ Object
:nodoc:
127 128 129 |
# File 'lib/active_fedora/relation/query_methods.rb', line 127 def none! # :nodoc: extending!(NullRelation) end |
#offset(value) ⇒ Object
Start the returned records at an offset position. Useful for paginated results
118 119 120 |
# File 'lib/active_fedora/relation/query_methods.rb', line 118 def offset(value) spawn.offset!(value) end |
#offset!(value) ⇒ Object
122 123 124 125 |
# File 'lib/active_fedora/relation/query_methods.rb', line 122 def offset!(value) self.offset_value = value self end |
#offset_value ⇒ Object
39 40 41 |
# File 'lib/active_fedora/relation/query_methods.rb', line 39 def offset_value @values[:offset] end |
#offset_value=(value) ⇒ Object
43 44 45 46 |
# File 'lib/active_fedora/relation/query_methods.rb', line 43 def offset_value=(value) raise ImmutableRelation if loaded? @values[:offset] = value end |
#order(*args) ⇒ Object
Order the returned records by the field and direction provided
85 86 87 |
# File 'lib/active_fedora/relation/query_methods.rb', line 85 def order(*args) spawn.order!(args) end |
#order!(*args) ⇒ Object
89 90 91 92 |
# File 'lib/active_fedora/relation/query_methods.rb', line 89 def order!(*args) self.order_values += args.flatten self end |
#order_values ⇒ Object
21 22 23 |
# File 'lib/active_fedora/relation/query_methods.rb', line 21 def order_values @values[:order] || [] end |
#order_values=(values) ⇒ Object
25 26 27 28 |
# File 'lib/active_fedora/relation/query_methods.rb', line 25 def order_values=(values) raise ImmutableRelation if @loaded @values[:order] = values end |
#select ⇒ Object
141 142 143 |
# File 'lib/active_fedora/relation/query_methods.rb', line 141 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
55 56 57 |
# File 'lib/active_fedora/relation/query_methods.rb', line 55 def where(values) spawn.where!(values) end |
#where!(values) ⇒ Object
59 60 61 62 |
# File 'lib/active_fedora/relation/query_methods.rb', line 59 def where!(values) self.where_values += build_where(values) self end |
#where_values ⇒ Object
12 13 14 |
# File 'lib/active_fedora/relation/query_methods.rb', line 12 def where_values @values[:where] ||= [] end |
#where_values=(values) ⇒ Object
16 17 18 19 |
# File 'lib/active_fedora/relation/query_methods.rb', line 16 def where_values=(values) raise ImmutableRelation if @loaded @values[:where] = values end |