Sha256: 0cc8e7dedad8c9d43a8dc46f9a9724c186a3834b4377d3bdf356313ffe44b2e3
Contents?: true
Size: 1.12 KB
Versions: 11
Compression:
Stored size: 1.12 KB
Contents
module Rivendell::Import::Tasking module Status def define_default_status self.status ||= "pending" end def self.included(base) base.class_eval do after_initialize :define_default_status end base.extend ClassMethods end def raw_status read_attribute(:status) end def status ActiveSupport::StringInquirer.new(raw_status) if raw_status end def change_status!(status) logger.debug "Change status to #{status}" update_attribute :status, status.to_s # notify! if ran? invoke_status_changed_callbacks end def invoke_status_changed_callbacks callbacks = self.class.status_changed_callbacks.values_at(:all, status.to_sym).flatten callbacks.each { |method| send method } end module ClassMethods def status_changed_callbacks @status_changed_callbacks ||= Hash.new { |h,k| h[k] = [] } end def after_status_changed(method, options = {}) Array(options[:on] || :all).each do |status| status_changed_callbacks[status] << method end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems