Module: DoorkeeperSequel::SequelCompat::ClassMethods
- Defined in:
- lib/doorkeeper-sequel/mixins/concerns/sequel_compat.rb
Instance Method Summary collapse
- #create!(values = {}, &block) ⇒ Object
- #exists?(*args) ⇒ Boolean
-
#find(*args, &block) ⇒ Object
find(1) or find(“1”) - will work like find(id: 1) find(name: ‘John’) - will work like find(name: ‘John’).
- #ordered_by(attribute, direction = :asc) ⇒ Object
- #table_exists? ⇒ Boolean
Instance Method Details
#create!(values = {}, &block) ⇒ Object
46 47 48 |
# File 'lib/doorkeeper-sequel/mixins/concerns/sequel_compat.rb', line 46 def create!(values = {}, &block) new(values, &block).save(raise_on_failure: true) end |
#exists?(*args) ⇒ Boolean
68 69 70 71 72 73 74 |
# File 'lib/doorkeeper-sequel/mixins/concerns/sequel_compat.rb', line 68 def exists?(*args) if args.any? !where(*args).empty? else !empty? end end |
#find(*args, &block) ⇒ Object
find(1) or find(“1”) - will work like find(id: 1) find(name: ‘John’) - will work like find(name: ‘John’)
60 61 62 63 64 65 66 |
# File 'lib/doorkeeper-sequel/mixins/concerns/sequel_compat.rb', line 60 def find(*args, &block) if args.first.is_a?(Hash) super(*args, &block) else super(id: args) end end |
#ordered_by(attribute, direction = :asc) ⇒ Object
54 55 56 |
# File 'lib/doorkeeper-sequel/mixins/concerns/sequel_compat.rb', line 54 def ordered_by(attribute, direction = :asc) order(::Sequel.public_send(direction, attribute)) end |
#table_exists? ⇒ Boolean
50 51 52 |
# File 'lib/doorkeeper-sequel/mixins/concerns/sequel_compat.rb', line 50 def table_exists? db.table_exists?(table_name) end |