Module: Achievable::AchieveManager

Extended by:
ActiveSupport::Concern
Included in:
Achiever
Defined in:
lib/achievable/achieve_manager.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.perform(opts = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/achievable/achieve_manager.rb', line 17

def self.perform(opts={})
  inst = opts["class"].constantize.find(opts["id"])
  condition = eval(opts["condition"]) if opts["condition"] 
  if condition
    inst.achieveit!(opts["name"], &condition) 
  else
    inst.achieveit!(opts["name"])
  end
end

Instance Method Details

#achieveit(name, &block) ⇒ Object



12
13
14
15
# File 'lib/achievable/achieve_manager.rb', line 12

def achieveit(name, &block)
  block_source = block_given? ? block.to_source : nil
  Resque.enqueue(AchieveManager, {"name" => name, "id" => self.id, "class" => self.class.to_s, "condition" => block_source})
end

#achieveit!(name) ⇒ Object

Raises:

  • (NotImplementedError)


8
9
10
# File 'lib/achievable/achieve_manager.rb', line 8

def achieveit!(name)
  raise NotImplementedError
end