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.
18 19 20 21 22 |
# File 'lib/translate_enum/builder.rb', line 18 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.
14 15 16 |
# File 'lib/translate_enum/builder.rb', line 14 def attribute @attribute end |
#enum_instance_method_name ⇒ Object
Returns the value of attribute enum_instance_method_name.
8 9 10 |
# File 'lib/translate_enum/builder.rb', line 8 def enum_instance_method_name @enum_instance_method_name end |
#enum_klass_method_name ⇒ Object
Returns the value of attribute enum_klass_method_name.
9 10 11 |
# File 'lib/translate_enum/builder.rb', line 9 def enum_klass_method_name @enum_klass_method_name end |
#i18n_key ⇒ Object
Returns the value of attribute i18n_key.
6 7 8 |
# File 'lib/translate_enum/builder.rb', line 6 def i18n_key @i18n_key end |
#i18n_scope ⇒ Object
like “activerecord.attributes” or “activemodel.attributes”
25 26 27 |
# File 'lib/translate_enum/builder.rb', line 25 def i18n_scope @i18n_scope end |
#method_name_plural ⇒ Object
like “translated_genders”
43 44 45 |
# File 'lib/translate_enum/builder.rb', line 43 def method_name_plural @method_name_plural end |
#method_name_singular ⇒ Object
like “translated_gender”
49 50 51 |
# File 'lib/translate_enum/builder.rb', line 49 def method_name_singular @method_name_singular end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
14 15 16 |
# File 'lib/translate_enum/builder.rb', line 14 def model @model end |
Instance Method Details
#i18n_default_location(key) ⇒ Object
37 38 39 |
# File 'lib/translate_enum/builder.rb', line 37 def i18n_default_location(key) :"attributes.#{i18n_key}.#{key}" end |
#i18n_location(key) ⇒ Object
33 34 35 |
# File 'lib/translate_enum/builder.rb', line 33 def i18n_location(key) "#{model.model_name.i18n_key}.#{i18n_key}.#{key}" end |