class EacRubyUtils::Enum::Value
def <=>(other)
def <=>(other) key <=> other.key end
def apply
def apply define_constant define_class_method self end
def class_method_name
-
(String)
-
def class_method_name key.to_s end
def constant_name
-
(String)
-
def constant_name class_method_name.upcase end
def define_class_method
def define_class_method the_value = self klass.define_singleton_method(class_method_name) { the_value.value } end
def define_constant
def define_constant klass.const_set(constant_name, value) end
def initialize(klass, key, args, &block)
def initialize(klass, key, args, &block) @klass = klass @key = ::EacRubyUtils::Inflector.variableize(key.to_s).to_sym @args = args @block = block end
def uncached_value
def uncached_value klass.new(key, *value_args) end
def value
def value @value ||= uncached_value end
def value_args
def value_args r = if block block.call elsif args.count == 1 && args.first.is_a?(::Enumerable) args.first else args end r.is_a?(::Enumerable) ? r : [r] end