Sha256: 0680c71ed18364797d6dfdb543893db912f56379909ca2c54db59c17be313385

Contents?: true

Size: 784 Bytes

Versions: 4

Compression:

Stored size: 784 Bytes

Contents

class Kit::Bit < ActiveRecord::Base

  belongs_to :group
  has_many :permissions
  has_many :users, :through => :permissions

  after_initialize do
    self.extend KitActionsDefault
    unless self.group.nil?
      mod = "KitActions#{self.group.name.gsub(' ', '_').camelize}"
      self.extend Kernel.const_get(mod) if Kernel.const_defined? mod
    end
  end

  class Job

    def initialize *args
      if args[0].is_a? Hash
        hash = args[0]
        args = [ hash[:config_file], hash[:bit_id], hash[:action], *hash[:args] ]
      end
      @config_file = args[0]
      @bit_id      = args[1]
      @action      = args[2]
      @args        = *args[3..-1]
    end

    def perform
      Kit.open @config_file
      Kit::Bit.find(@bit_id).send(@action, *@args)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kit-1.2.0 lib/kit/models/bit.rb
kit-1.1.4 lib/kit/models/bit.rb
kit-1.1.2 lib/kit/models/bit.rb
kit-1.1.1 lib/kit/models/bit.rb