Class: UserQuery::Generator
- Inherits:
-
Object
- Object
- UserQuery::Generator
- Defined in:
- lib/user_query/generator.rb
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#expr ⇒ Object
Outputs.
-
#target ⇒ Object
Returns the value of attribute target.
-
#type ⇒ Object
Inputs.
-
#values ⇒ Object
Returns the value of attribute values.
-
#values_inline ⇒ Object
Returns the value of attribute values_inline.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#initialize(*opts) ⇒ Generator
constructor
A new instance of Generator.
- #sql(expr) ⇒ Object
Constructor Details
#initialize(*opts) ⇒ Generator
Returns a new instance of Generator.
16 17 18 19 20 21 22 |
# File 'lib/user_query/generator.rb', line 16 def initialize(*opts) self.target = '<<TARGET>>' self.values_inline = true self.type = :string opts = Hash[*opts] opts.each{|k, v| self.send("#{k}=", v)} end |
Instance Attribute Details
#expr ⇒ Object
Outputs
13 14 15 |
# File 'lib/user_query/generator.rb', line 13 def expr @expr end |
#target ⇒ Object
Returns the value of attribute target.
9 10 11 |
# File 'lib/user_query/generator.rb', line 9 def target @target end |
#type ⇒ Object
Inputs
7 8 9 |
# File 'lib/user_query/generator.rb', line 7 def type @type end |
#values ⇒ Object
Returns the value of attribute values.
14 15 16 |
# File 'lib/user_query/generator.rb', line 14 def values @values end |
#values_inline ⇒ Object
Returns the value of attribute values_inline.
8 9 10 |
# File 'lib/user_query/generator.rb', line 8 def values_inline @values_inline end |
#verbose ⇒ Object
Returns the value of attribute verbose.
10 11 12 |
# File 'lib/user_query/generator.rb', line 10 def verbose @verbose end |
Instance Method Details
#sql(expr) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/user_query/generator.rb', line 24 def sql(expr) @values = [ ] @expr = '' return nil if expr.nil? emit_sql(expr) @expr end |