Class: PostPolicy::DataSource::Sql
- Defined in:
- lib/postpolicy/plugins/datasource/sql.rb
Instance Method Summary collapse
- #exists?(value) ⇒ Boolean
-
#initialize(query) ⇒ Sql
constructor
A new instance of Sql.
Constructor Details
#initialize(query) ⇒ Sql
Returns a new instance of Sql.
6 7 8 |
# File 'lib/postpolicy/plugins/datasource/sql.rb', line 6 def initialize( query ) @query = query end |
Instance Method Details
#exists?(value) ⇒ Boolean
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/postpolicy/plugins/datasource/sql.rb', line 10 def exists?( value ) result = false connection do |conn| command = conn.create_command( @query ) reader = command.execute_reader while reader.next! if reader.values[0] && reader.values[0] == value result = true break end end end result end |