Sha256: c88aac15897c4299a0157c9a507bc9c834dc591de21cdc43d0d5d6dd53e9a22f
Contents?: true
Size: 1 KB
Versions: 11
Compression:
Stored size: 1 KB
Contents
module Martyr module Schema class NamedScopeCollection < HashWithIndifferentAccess include Martyr::Registrable # = DSL def scope(name, proc) named_scope = NamedScope.new(name, proc) register(named_scope) add_to_cube_helper_module(named_scope) add_to_query_helper_module(named_scope) end def cube_helper_module @cube_helper_module ||= Module.new end def query_helper_module @query_helper_module ||= Module.new end private # Delegates all named scopes to #new_query_context_builder def add_to_cube_helper_module(named_scope) cube_helper_module.module_eval do delegate named_scope.name, to: :new_query_context_builder end end def add_to_query_helper_module(named_scope) query_helper_module.module_eval do define_method(named_scope.name) do |*args| named_scope.run(self, *args) end end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems