Class: ArTranslate::TranslatedColumn

Inherits:
Object
  • Object
show all
Defined in:
lib/ar_translate/translated_column.rb

Constant Summary collapse

KEYWORDS =
%w(attributes languages).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, column, opts) ⇒ TranslatedColumn

Returns a new instance of TranslatedColumn.



8
9
10
11
12
13
14
15
# File 'lib/ar_translate/translated_column.rb', line 8

def initialize(model, column, opts)
  @model = model
  @column = column.to_s
  @langs = opts.delete(:languages)

  check_plural_name!
  check_languages!
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



6
7
8
# File 'lib/ar_translate/translated_column.rb', line 6

def column
  @column
end

#modelObject (readonly)

Returns the value of attribute model.



6
7
8
# File 'lib/ar_translate/translated_column.rb', line 6

def model
  @model
end

Instance Method Details

#injectObject



17
18
19
20
21
22
23
24
25
# File 'lib/ar_translate/translated_column.rb', line 17

def inject
  define_attributes
  define_languages

  langs.each do |lang|
    define_reader(lang)
    define_writer(lang)
  end
end