ScopeRegistry

Stolen from ActiveRecord https://github.com/rails/rails/blob/08754f12e65a9ec79633a605e986d0f1ffa4b251/activerecord/lib/active_record/scoping.rb#L57

Constants

  • VALID_SCOPE_TYPES

Methods

#initialize

def initialize
  @registry = Hash.new { |hash, key| hash[key] = {} }
end
#set_value_for

Sets the +value+ for a given +scope_type+ and +variable_name+.

def set_value_for(scope_type, variable_name, value)
  raise_invalid_scope_type!(scope_type)
  @registry[scope_type][variable_name] = value
end
#value_for

Obtains the value for a given +scope_name+ and +variable_name+.

def value_for(scope_type, variable_name)
  raise_invalid_scope_type!(scope_type)
  @registry[scope_type][variable_name]
end