class SimpleEnumeration::Type
Constants
- VALUE_METHOD_NAME_SUFFIX
- VALUE_PREDICATE_METHOD_NAME_SUFFIX
Attributes
converted_value[R]
definition[R]
enum_class[R]
value[R]
Public Class Methods
new(definition:, value:, converted_value:, enum_class:)
click to toggle source
# File lib/simple_enumeration/type.rb, line 7 def initialize(definition:, value:, converted_value:, enum_class:) @definition = definition @value = value @converted_value = converted_value @enum_class = enum_class end
type_value_for_method_name(method_name)
click to toggle source
# File lib/simple_enumeration/type.rb, line 17 def self.type_value_for_method_name(method_name) method_name.to_s end
type_value_for_value_method_name(method_name)
click to toggle source
# File lib/simple_enumeration/type.rb, line 21 def self.type_value_for_value_method_name(method_name) method_name.to_s.gsub(VALUE_METHOD_NAME_SUFFIX, '') end
type_value_for_value_predicate_method_name(method_name)
click to toggle source
# File lib/simple_enumeration/type.rb, line 25 def self.type_value_for_value_predicate_method_name(method_name) method_name.to_s.gsub(VALUE_PREDICATE_METHOD_NAME_SUFFIX, '') end
Public Instance Methods
for_select()
click to toggle source
# File lib/simple_enumeration/type.rb, line 41 def for_select [humanized, converted_value] end
humanized()
click to toggle source
# File lib/simple_enumeration/type.rb, line 45 def humanized translations[:text] end
meta()
click to toggle source
# File lib/simple_enumeration/type.rb, line 49 def meta translations.except(:text) end
method_name()
click to toggle source
# File lib/simple_enumeration/type.rb, line 29 def method_name value end
translations()
click to toggle source
# File lib/simple_enumeration/type.rb, line 53 def translations I18n.t( value, raise: true, scope: enum_class.i18n_scope ) end
value_method_name()
click to toggle source
# File lib/simple_enumeration/type.rb, line 33 def value_method_name [value, VALUE_METHOD_NAME_SUFFIX].join end
value_predicate_method_name()
click to toggle source
# File lib/simple_enumeration/type.rb, line 37 def value_predicate_method_name [value, VALUE_PREDICATE_METHOD_NAME_SUFFIX].join end