module Norton::Helper::ClassMethods
Attributes
norton_values[R]
Public Instance Methods
norton_value_defined?(name)
click to toggle source
当前类是否定义了某个 Norton
Value
@param [String/Symbol] name
@return [Boolean]
# File lib/norton/helper.rb, line 33 def norton_value_defined?(name) norton_values.has_key?(name.to_sym) end
norton_value_redis_pool(name)
click to toggle source
返回当前类定义的某个 Norton
Value 的 redis instance
@param [String] name
@return [ConnectionPool]
# File lib/norton/helper.rb, line 55 def norton_value_redis_pool(name) pool_name = norton_values.dig(name.to_sym, :redis) || :default Norton.pools[pool_name] end
norton_value_type(name)
click to toggle source
返回当前类定义的某个 Norton
Value 的类型
@param [String] name
@return [Symbol]
# File lib/norton/helper.rb, line 44 def norton_value_type(name) norton_values.dig(name.to_sym, :type) end
register_norton_value(name, norton_type, options = {})
click to toggle source
当定义一个 Norton
Value 的时候,将这个 Norton
Value 记录在 Class Variable `@norton_values` 中
@return [void]
# File lib/norton/helper.rb, line 18 def register_norton_value(name, norton_type, options = {}) if !Norton::SUPPORTED_TYPES.include?(norton_type.to_sym) raise Norton::InvalidType.new("Norton Type: #{norton_type} invalid!") end @norton_values[name.to_sym] = options.symbolize_keys.merge(:type => norton_type.to_sym) end