Class: Translatable::Base
- Inherits:
-
Object
- Object
- Translatable::Base
- Defined in:
- lib/translatable/base.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#origin_key ⇒ Object
readonly
Returns the value of attribute origin_key.
-
#origin_reflection_name ⇒ Object
(also: #or_name)
readonly
Returns the value of attribute origin_reflection_name.
-
#translation_model ⇒ Object
(also: #t_model)
readonly
ACCESS.
Instance Method Summary collapse
- #class_name(model_name) ⇒ Object
-
#field(*args) ⇒ Object
API.
- #foreign_key(key_name) ⇒ Object
-
#initialize(origin_model) ⇒ Base
constructor
A new instance of Base.
- #locale_column ⇒ Object
- #locale_key(key_name, opts = {}) ⇒ Object
- #mapping ⇒ Object
- #reflection_name(reflection) ⇒ Object
Constructor Details
#initialize(origin_model) ⇒ Base
Returns a new instance of Base.
5 6 7 |
# File 'lib/translatable/base.rb', line 5 def initialize origin_model @origin_model = origin_model end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
3 4 5 |
# File 'lib/translatable/base.rb', line 3 def fields @fields end |
#origin_key ⇒ Object (readonly)
Returns the value of attribute origin_key.
3 4 5 |
# File 'lib/translatable/base.rb', line 3 def origin_key @origin_key end |
#origin_reflection_name ⇒ Object (readonly) Also known as: or_name
Returns the value of attribute origin_reflection_name.
3 4 5 |
# File 'lib/translatable/base.rb', line 3 def origin_reflection_name @origin_reflection_name end |
#translation_model ⇒ Object (readonly) Also known as: t_model
ACCESS
32 33 34 |
# File 'lib/translatable/base.rb', line 32 def translation_model @translation_model end |
Instance Method Details
#class_name(model_name) ⇒ Object
14 15 16 |
# File 'lib/translatable/base.rb', line 14 def class_name(model_name) @translation_model = prepare_model model_name end |
#field(*args) ⇒ Object
API
10 11 12 |
# File 'lib/translatable/base.rb', line 10 def field(*args) (@fields ||= []) << set_mapping(*args) end |
#foreign_key(key_name) ⇒ Object
18 19 20 |
# File 'lib/translatable/base.rb', line 18 def foreign_key(key_name) @origin_key = key_name.to_sym end |
#locale_column ⇒ Object
46 47 48 |
# File 'lib/translatable/base.rb', line 46 def locale_column @locale_column || (@locale_column = :locale) end |
#locale_key(key_name, opts = {}) ⇒ Object
26 27 28 29 |
# File 'lib/translatable/base.rb', line 26 def locale_key(key_name, opts = {}) set_mapping key_name, opts @locale_column = key_name.to_sym end |
#mapping ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/translatable/base.rb', line 50 def mapping unless @mapping_defined (@mapping ||= {})[locale_column] ||= :locale @mapping_defined = true end @mapping || {} end |
#reflection_name(reflection) ⇒ Object
22 23 24 |
# File 'lib/translatable/base.rb', line 22 def reflection_name(reflection) @origin_reflection_name = reflection.to_sym end |