Sha256: 1f7156dcc9d0a00492af33519e41c49bc44bbb16b8039e18fa5677c980860508
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
# frozen_string_literal: true require 'sequel' require 'forwardable' module Rack::Scaffold::Adapters class Sequel < Base extend Forwardable def_delegators :@klass, :count, :all, :find, :[], :update_timestamp_field def_delegator :@klass, :create, :create! def_delegator :@klass, :update, :update! def_delegator :@klass, :destroy, :destroy! class << self def ===(model) ::Sequel::Model === model end def resources(model, _options = {}) model end end def singular @klass.name.demodulize.downcase end def plural @klass.table_name end def paginate(limit, offset) @klass.limit(limit, offset) end def one_to_many_associations @klass.all_association_reflections.select { |association| association[:type] == :one_to_many }.collect { |association| association[:name] } end def timestamps? defined?(::Sequel::Plugins::Timestamps) && @klass.plugins.include?(::Sequel::Plugins::Timestamps) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rack-scaffold-0.2.2 | ./lib/rack/scaffold/adapters/sequel.rb |