Sha256: cfd60dba2f8c6eacf77353c8bed5ccb678730016e4562dbd82a6b97dcefc49e7

Contents?: true

Size: 783 Bytes

Versions: 1

Compression:

Stored size: 783 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

1 entries across 1 versions & 1 rubygems

Version Path
kit-1.1.0 lib/kit/models/bit.rb