Module: AppQuery
- Defined in:
- lib/app_query.rb,
lib/app_query/base.rb,
lib/app_query/version.rb,
lib/app_query/tokenizer.rb,
lib/app_query/render_helpers.rb
Overview
AppQuery provides a way to work with raw SQL queries using ERB templating, parameter binding, and CTE manipulation.
Defined Under Namespace
Modules: RenderHelpers Classes: Base, Configuration, Error, Q, Result, Tokenizer, UnrenderedQueryError
Constant Summary collapse
- VERSION =
"0.4.0"
Class Method Summary collapse
-
.[](query_name, **opts) ⇒ Q
Loads a query from a file in the configured query path.
-
.configuration ⇒ Configuration
Returns the current configuration.
-
.configure {|Configuration| ... } ⇒ Object
Yields the configuration for modification.
-
.reset_configuration! ⇒ void
Resets configuration to default values.
Class Method Details
.[](query_name, **opts) ⇒ Q
Loads a query from a file in the configured query path.
87 88 89 90 91 |
# File 'lib/app_query.rb', line 87 def self.[](query_name, **opts) filename = File.extname(query_name.to_s).empty? ? "#{query_name}.sql" : query_name.to_s full_path = (Pathname.new(configuration.query_path) / filename). Q.new(full_path.read, name: "AppQuery #{query_name}", filename: full_path.to_s, **opts) end |
.configuration ⇒ Configuration
Returns the current configuration.
47 48 49 |
# File 'lib/app_query.rb', line 47 def self.configuration @configuration ||= AppQuery::Configuration.new end |
.configure {|Configuration| ... } ⇒ Object
Yields the configuration for modification.
59 60 61 |
# File 'lib/app_query.rb', line 59 def self.configure yield configuration if block_given? end |
.reset_configuration! ⇒ void
This method returns an undefined value.
Resets configuration to default values.
66 67 68 69 70 |
# File 'lib/app_query.rb', line 66 def self.reset_configuration! configure do |config| config.query_path = "app/queries" end end |