Sha256: 38ca1744cd6dc21c396ff34399e2503f45a6e7212ed88a5484274b8c71097b0f

Contents?: true

Size: 832 Bytes

Versions: 3

Compression:

Stored size: 832 Bytes

Contents

module Quandl
module Command
class Task

module Callbacks
  
  extend ActiveSupport::Concern

  included do
  
    extend ActiveModel::Callbacks
    define_model_callbacks :execute
    
    before_execute :run_task_validations!
    
  end

  module ClassMethods
    
    def disable_in_gem!
      before_execute :disable_in_gem!
    end
  
  end
  
  def run_task_validations!
    unless valid?
      error( table(errors.full_messages) )
      false
    end
  end
  
  def disable_in_gem!
    if force_yes?
      info("You have forced update!")
      true
    elsif Dir.exists?( File.join( Tasks.root, ".git") ) || File.exists?( File.join( Tasks.root, "Gemfile") )
      fatal("#{self.class.command_name} is only permitted when installed as a package! http://quandl.com/help/toolbelt") 
      false
    end
  end
  
end

end
end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
quandl-0.3.4 lib/quandl/command/task/callbacks.rb
quandl-0.3.3 lib/quandl/command/task/callbacks.rb
quandl-0.3.0 lib/quandl/command/task/callbacks.rb