Module: SQLRunner::Query::One
- Defined in:
- lib/sql_runner/query/one.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.activate(target, _options) ⇒ Object
4 5 6 |
# File 'lib/sql_runner/query/one.rb', line 4 def self.activate(target, ) target.singleton_class.prepend self end |
Instance Method Details
#call(**bind_vars) ⇒ Object
8 9 10 11 |
# File 'lib/sql_runner/query/one.rb', line 8 def call(**bind_vars) result = super(**bind_vars) result.to_a.first end |
#call!(**bind_vars) ⇒ Object
13 14 15 |
# File 'lib/sql_runner/query/one.rb', line 13 def call!(**bind_vars) call(**bind_vars) or fail SQLRunner::RecordNotFound, "#{name}: record was not found with #{bind_vars.inspect} arguments" end |