Class: TranslateEnum::Builder
- Inherits:
-
Object
- Object
- TranslateEnum::Builder
- Defined in:
- lib/translate_enum/builder.rb
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#enum_instance_method_name ⇒ Object
Returns the value of attribute enum_instance_method_name.
-
#enum_klass_method_name ⇒ Object
Returns the value of attribute enum_klass_method_name.
-
#i18n_key ⇒ Object
Returns the value of attribute i18n_key.
-
#i18n_scope ⇒ Object
like “activerecord.attributes” or “activemodel.attributes”.
-
#method_name_plural ⇒ Object
like “translated_genders”.
-
#method_name_singular ⇒ Object
like “translated_gender”.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
- #i18n_default_location(key) ⇒ Object
- #i18n_location(key) ⇒ Object
-
#initialize(model, attribute) {|_self| ... } ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize(model, attribute) {|_self| ... } ⇒ Builder
Returns a new instance of Builder.
16 17 18 19 20 |
# File 'lib/translate_enum/builder.rb', line 16 def initialize(model, attribute) @model = model @attribute = attribute yield(self) if block_given? end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
12 13 14 |
# File 'lib/translate_enum/builder.rb', line 12 def attribute @attribute end |
#enum_instance_method_name ⇒ Object
Returns the value of attribute enum_instance_method_name.
6 7 8 |
# File 'lib/translate_enum/builder.rb', line 6 def enum_instance_method_name @enum_instance_method_name end |
#enum_klass_method_name ⇒ Object
Returns the value of attribute enum_klass_method_name.
7 8 9 |
# File 'lib/translate_enum/builder.rb', line 7 def enum_klass_method_name @enum_klass_method_name end |
#i18n_key ⇒ Object
Returns the value of attribute i18n_key.
4 5 6 |
# File 'lib/translate_enum/builder.rb', line 4 def i18n_key @i18n_key end |
#i18n_scope ⇒ Object
like “activerecord.attributes” or “activemodel.attributes”
23 24 25 |
# File 'lib/translate_enum/builder.rb', line 23 def i18n_scope @i18n_scope end |
#method_name_plural ⇒ Object
like “translated_genders”
41 42 43 |
# File 'lib/translate_enum/builder.rb', line 41 def method_name_plural @method_name_plural end |
#method_name_singular ⇒ Object
like “translated_gender”
47 48 49 |
# File 'lib/translate_enum/builder.rb', line 47 def method_name_singular @method_name_singular end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
12 13 14 |
# File 'lib/translate_enum/builder.rb', line 12 def model @model end |
Instance Method Details
#i18n_default_location(key) ⇒ Object
35 36 37 |
# File 'lib/translate_enum/builder.rb', line 35 def i18n_default_location(key) :"attributes.#{i18n_key}.#{key}" end |
#i18n_location(key) ⇒ Object
31 32 33 |
# File 'lib/translate_enum/builder.rb', line 31 def i18n_location(key) "#{model.model_name.i18n_key}.#{i18n_key}.#{key}" end |