Class: Transform::Railtie

Inherits:
Rails::Railtie
  • Object
show all
Defined in:
lib/transform/railtie.rb

Class Method Summary collapse

Class Method Details

.extend_active_recordObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/transform/railtie.rb', line 5

def self.extend_active_record
  
  ActiveRecord::Base.class_eval do
  
    def self.transform(params={})
      instance_eval do
        @@tc = TransformerChain.new(params)
      end
      self.column_names.each do |c|
        class_eval do
          define_method("#{c}=".to_sym) do |v|
            self[c.to_sym]= @@tc.apply c.to_sym, v
          end
        end
      end
  
    end
  end
end