module Aliyun::Log::Record::Scoping::ClassMethods

Public Instance Methods

all() click to toggle source
# File lib/aliyun/log/record/scoping.rb, line 41
def all
  scope = current_scope
  scope ||= relation.from(0).to(Time.now.to_i)
  scope
end
current_scope() click to toggle source
# File lib/aliyun/log/record/scoping.rb, line 19
def current_scope
  ScopeRegistry.value_for(:current_scope, self)
end
current_scope=(scope) click to toggle source
# File lib/aliyun/log/record/scoping.rb, line 23
def current_scope=(scope)
  ScopeRegistry.set_value_for(:current_scope, self, scope)
end
scope(name, body) click to toggle source
# File lib/aliyun/log/record/scoping.rb, line 27
def scope(name, body)
  raise ArgumentError, 'The scope body needs to be callable.' unless body.respond_to?(:call)

  singleton_class.send(:define_method, name) do |*args|
    scope = all
    scope = scope.scoping { body.call(*args) }
    scope
  end
end
unscoped() { || ... } click to toggle source
# File lib/aliyun/log/record/scoping.rb, line 37
def unscoped
  block_given? ? relation.scoping { yield } : relation
end

Private Instance Methods

relation() click to toggle source
# File lib/aliyun/log/record/scoping.rb, line 49
def relation
  Relation.new(self)
end