Class: Zena::Use::QueryBuilder::ZafuMethods::DynamicQuery
- Inherits:
-
Object
- Object
- Zena::Use::QueryBuilder::ZafuMethods::DynamicQuery
- Defined in:
- lib/zena/use/query_builder.rb
Overview
Dynamic query mocks the QueryBuilder::Query
Instance Method Summary collapse
-
#initialize(default, node, sql, count) ⇒ DynamicQuery
constructor
A new instance of DynamicQuery.
-
#method_missing(meth, *args) ⇒ Object
Pass all other methods to the default query.
- #to_s(type = :find) ⇒ Object
Constructor Details
#initialize(default, node, sql, count) ⇒ DynamicQuery
Returns a new instance of DynamicQuery.
164 165 166 |
# File 'lib/zena/use/query_builder.rb', line 164 def initialize(default, node, sql, count) @default, @node, @sql, @count = default, node, sql, count end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args) ⇒ Object
Pass all other methods to the default query.
179 180 181 |
# File 'lib/zena/use/query_builder.rb', line 179 def method_missing(meth, *args) @default.send(meth, *args) end |
Instance Method Details
#to_s(type = :find) ⇒ Object
168 169 170 171 172 173 174 175 176 |
# File 'lib/zena/use/query_builder.rb', line 168 def to_s(type = :find) base = "'#{@node.klass}', #{@node.to_s.inspect}, #{@sql}, :find => #{@count.inspect}, :binding => binding" case type when :find return "query(#{base})" else return "query(#{base}, :type => #{type.inspect})" end end |