Class: TranslateEnum::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/translate_enum/builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, attribute) {|_self| ... } ⇒ Builder

Returns a new instance of Builder.

Parameters:

  • model (ActiveModel::Model, ActiveRecord::Base)
  • attribute (String)

Yields:

  • (_self)

Yield Parameters:



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

#attributeObject (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_nameObject

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_nameObject

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_keyObject

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_scopeObject

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_pluralObject

like “translated_genders”

Parameters:

  • (String)


41
42
43
# File 'lib/translate_enum/builder.rb', line 41

def method_name_plural
  @method_name_plural
end

#method_name_singularObject

like “translated_gender”

Parameters:

  • (String)


47
48
49
# File 'lib/translate_enum/builder.rb', line 47

def method_name_singular
  @method_name_singular
end

#modelObject (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