Module: EnumStyle::Helper

Defined in:
lib/enum_style/style.rb

Class Method Summary collapse

Class Method Details

.define_attr_style_method(klass, attr_name) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/enum_style/style.rb', line 23

def self.define_attr_style_method(klass, attr_name)

  attr_style_method_name = "#{attr_name}_style"

  klass.define_method(attr_style_method_name) do

    styles = EnumStyles[klass.to_s.underscore]

    styles ? styles[attr_name.to_s][self.send(attr_name)] : nil
  end
end