Class: ActiveRecord::SqlMapper::Context
- Inherits:
-
Object
- Object
- ActiveRecord::SqlMapper::Context
- Includes:
- Singleton
- Defined in:
- lib/sql_mapper.rb
Instance Method Summary collapse
-
#initialize ⇒ Context
constructor
A new instance of Context.
- #map(name, sql, result_class = nil) ⇒ Object
- #named_query_exists?(sym) ⇒ Boolean
- #queries ⇒ Object
- #result_class(clazz = nil) ⇒ Object
Constructor Details
#initialize ⇒ Context
Returns a new instance of Context.
23 24 25 26 |
# File 'lib/sql_mapper.rb', line 23 def initialize @default_result_class = Struct @queries = {} end |
Instance Method Details
#map(name, sql, result_class = nil) ⇒ Object
36 37 38 39 |
# File 'lib/sql_mapper.rb', line 36 def map(name, sql, result_class=nil) mapping = QueryMapping.new name, sql, result_class @queries[name] = mapping end |
#named_query_exists?(sym) ⇒ Boolean
32 33 34 |
# File 'lib/sql_mapper.rb', line 32 def named_query_exists?(sym) @queries.include? sym end |
#queries ⇒ Object
28 29 30 |
# File 'lib/sql_mapper.rb', line 28 def queries @queries.dup end |
#result_class(clazz = nil) ⇒ Object
41 42 43 44 |
# File 'lib/sql_mapper.rb', line 41 def result_class(clazz=nil) @default_result_class = clazz if not clazz.nil? and clazz.is_a? Class @default_result_class end |