Sha256: d53211d323547602d270e306db0c353b7057d9eba9679a6038adbf66e9d8cedf

Contents?: true

Size: 610 Bytes

Versions: 3

Compression:

Stored size: 610 Bytes

Contents

module DataMiner
  class Target < ActiveRecord::Base
    set_table_name 'data_miner_targets'
    set_primary_key :name
    has_many :runs, :class_name => '::DataMiner::Run', :foreign_key => 'data_miner_target_id'

    def klass
      name.constantize
    end
    
    def run
      klass.data_miner_config.run
    end

    def included_in_list_of_targets
      msg = "must have a data_miner block"
      unless DataMiner.classes.include?(name.constantize)
        errors.add :name, msg
      end
    rescue NameError
      errors.add :name, msg
    end
    
    validate :included_in_list_of_targets
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
data_miner-0.3.3 lib/data_miner/target.rb
data_miner-0.3.2 lib/data_miner/target.rb
data_miner-0.3.1 lib/data_miner/target.rb