Class: BBMB::Model::Subject
- Inherits:
-
Object
- Object
- BBMB::Model::Subject
- Defined in:
- lib/bbmb/model/subject.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.multilingual(*keys) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/bbmb/model/subject.rb', line 10 def multilingual(*keys) @multilinguals ||= [] keys.each { |key| @multilinguals.push key name = "@#{key}" define_method(key) { instance_variable_get(name) or begin instance_variable_set(name, Util::Multilingual.new) end } define_method(:to_s) { self.send(key).to_s } ml = @multilinguals define_method(:multilinguals) { ml } protected attr_writer key } end |
Instance Method Details
#migrate_to_subject ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/bbmb/model/subject.rb', line 30 def migrate_to_subject changed = false multilinguals.each { |key| name = "@#{key}" if((var = instance_variable_get(name)) \ && !var.is_a?(Util::Multilingual)) changed = true ml = Util::Multilingual.new ml.de = var instance_variable_set(name, ml) end } changed end |