Sha256: 882ed93917b05f5a18e8453bc1a48dce4f7a7cffaa30ba032d698290a411ce2f

Contents?: true

Size: 559 Bytes

Versions: 2

Compression:

Stored size: 559 Bytes

Contents

module FlattenRecord
  module Meta
    class ComputeColumn < Column
      def initialize(parent, method, type, target_model, model, options={})
        @column = Struct.
          new(:name, :default, :type, :null). 
          new(method, options[:default], :integer, options[:null])  
        
        super(parent, @column, target_model, model) 
      end

      def denormalize(instance, to_record)
        assign_value(to_record, name) do |record|
          record.send("compute_#{@column.name}".to_sym, instance)
        end
      end 
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
flatten_record-1.0.5 lib/flatten_record/meta/compute_column.rb
flatten_record-1.0.4 lib/flatten_record/meta/compute_column.rb