Class: ActiveQuery::SQLTemplate
- Inherits:
-
Object
- Object
- ActiveQuery::SQLTemplate
- Defined in:
- lib/active_query/sql_template.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#templates ⇒ Object
readonly
Returns the value of attribute templates.
Instance Method Summary collapse
-
#initialize(config = Configuration.new) ⇒ SQLTemplate
constructor
A new instance of SQLTemplate.
- #load! ⇒ Object
Constructor Details
#initialize(config = Configuration.new) ⇒ SQLTemplate
Returns a new instance of SQLTemplate.
16 17 18 19 |
# File 'lib/active_query/sql_template.rb', line 16 def initialize(config = Configuration.new) @config = config @templates = [] end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
13 14 15 |
# File 'lib/active_query/sql_template.rb', line 13 def config @config end |
#templates ⇒ Object (readonly)
Returns the value of attribute templates.
14 15 16 |
# File 'lib/active_query/sql_template.rb', line 14 def templates @templates end |
Instance Method Details
#load! ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/active_query/sql_template.rb', line 21 def load! template_path = @config.template_path unless File.directory?(template_path) raise TemplatePathError, "error: #{template_path} template path is invalid, please make sure it exists." else Find.find(template_path) do |path| if File.basename(path) =~ /sql$/ sql = parse_sql(path) @templates << sql if sql end end end end |