Module: AssociationMethods

Defined in:
lib/interview/association_methods.rb

Instance Method Summary collapse

Instance Method Details

#define_readersObject

todo: überarbeiten



5
6
7
8
9
10
11
12
# File 'lib/interview/association_methods.rb', line 5

def define_readers
  super
  mixin.class_eval "    def \#{name}_human_ids_string\n      return self.\#{name}.human_ids.join(', ')\n    end\n  CODE\nend\n", __FILE__, __LINE__ + 1

#define_writersObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/interview/association_methods.rb', line 14

def define_writers
  super
  mixin.class_eval "    def \#{name}_human_ids_string=(string)\n      human_ids = string.split /, */\n      \#{name} = human_ids.map { |human_id| self.\#{name}.klass.find_by_human_id(human_id) }\n      self.\#{name} = \#{name}\n    end\n  CODE\nend\n", __FILE__, __LINE__ + 1