Module: Pathway::Plugins::SequelModels::InstanceMethods::Finder

Defined in:
lib/pathway/plugins/sequel_models.rb

Class Method Summary collapse

Class Method Details

.[](model_class, by: :id) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/pathway/plugins/sequel_models.rb', line 26

def self.[](model_class, by: :id)
  Module.new do
    include InstanceMethods

    define_singleton_method :included do |klass|
      klass.class_eval do
        result_at Inflecto.underscore(model_class.name.split('::').last).to_sym

        define_method(:model_class) { model_class }
        define_method(:field)       { by }
        define_method(:db)          { model_class.db }
      end
    end
  end
end