Sha256: 7606c46fcfcbf4631291b4bf3a4eecd3067809886ddcfed2bd9f6437fbf8157a

Contents?: true

Size: 790 Bytes

Versions: 2

Compression:

Stored size: 790 Bytes

Contents

class Kit::Bit < ActiveRecord::Base

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

  after_initialize do
    if self.group.nil?
      self.extend KitActionsDefault
    else
      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

2 entries across 2 versions & 1 rubygems

Version Path
kit-1.0.1 lib/kit/models/bit.rb
kit-1.0.0 lib/kit/models/bit.rb