Class: Helm::Query
Direct Known Subclasses
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
Returns the value of attribute db.
-
#result_class ⇒ Object
Returns the value of attribute result_class.
Instance Method Summary collapse
- #constraint ⇒ Object
- #each ⇒ Object
-
#initialize(conn_string) ⇒ Query
constructor
A new instance of Query.
- #print ⇒ Object
Constructor Details
#initialize(conn_string) ⇒ Query
Returns a new instance of Query.
7 8 9 |
# File 'lib/helm/query.rb', line 7 def initialize(conn_string) @db = Helm.databases[conn_string] end |
Instance Attribute Details
#db ⇒ Object (readonly)
Returns the value of attribute db.
11 12 13 |
# File 'lib/helm/query.rb', line 11 def db @db end |
#result_class ⇒ Object
Returns the value of attribute result_class.
12 13 14 |
# File 'lib/helm/query.rb', line 12 def result_class @result_class end |
Instance Method Details
#constraint ⇒ Object
14 15 16 |
# File 'lib/helm/query.rb', line 14 def constraint @constraint ||= @db end |
#each ⇒ Object
22 23 24 25 26 |
# File 'lib/helm/query.rb', line 22 def each constraint.select(*result_class.columns).each do |row| yield result_class.new(row) end end |
#print ⇒ Object
18 19 20 |
# File 'lib/helm/query.rb', line 18 def print constraint.print end |