Module: Riveter::Enquiry
- Extended by:
- ActiveSupport::Concern
- Included in:
- Base
- Defined in:
- lib/riveter/enquiry.rb
Defined Under Namespace
Modules: ClassMethods
Classes: Base
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
Returns the value of attribute query.
108
109
110
|
# File 'lib/riveter/enquiry.rb', line 108
def query
@query
end
|
Instance Method Details
#find_each(&block) ⇒ Object
110
111
112
|
# File 'lib/riveter/enquiry.rb', line 110
def find_each(&block)
self.query && self.query.find_each(&block)
end
|
#has_data? ⇒ Boolean
114
115
116
|
# File 'lib/riveter/enquiry.rb', line 114
def has_data?
self.query && self.query.has_data?
end
|
#initialize ⇒ Object
79
80
81
82
83
84
|
# File 'lib/riveter/enquiry.rb', line 79
def initialize
base_message = "#{self.class.name} enquiry not configured correctly."
raise "#{base_message} No query filter specified. Use the `filter_with` method to provide the query filter to use." unless self.class.respond_to?(:query_filter_class)
raise "#{base_message} No query specified. Use the `query_with` method to provide the query to use." unless self.class.respond_to?(:query_class)
end
|
#query_filter ⇒ Object
Also known as:
filter
86
87
88
|
# File 'lib/riveter/enquiry.rb', line 86
def query_filter
@query_filter ||= query_filter_class.new()
end
|
#query_filter_attributes ⇒ Object
91
92
93
|
# File 'lib/riveter/enquiry.rb', line 91
def query_filter_attributes
query_filter_class.attributes
end
|
#query_results ⇒ Object
118
119
120
|
# File 'lib/riveter/enquiry.rb', line 118
def query_results
self.query ? self.query.relation : nil
end
|
#submit(*args) ⇒ Object
95
96
97
98
99
100
101
102
103
104
105
106
|
# File 'lib/riveter/enquiry.rb', line 95
def submit(*args)
params = args.
@query_filter = create_query_filter(params)
return false unless @query_filter.valid?
@query = create_query(@query_filter)
end
|