Sha256: ff65dff02feca396d97d69b528b7df69d43a724d46a46b73785fb7586a8b5128

Contents?: true

Size: 620 Bytes

Versions: 1

Compression:

Stored size: 620 Bytes

Contents

# this version of eventable is meant to add event-like features to 1
# model, so we store it in one place
module Eventable

  class << self
    attr_accessor :model_name
  end

  #the model that's been made eventable by acts_as_event
  def self.model
    (
     model_name ||
     (detect_model_name if Rails.env.development?)
    ).constantize
  end

  private

  def self.detect_model_name
    File.basename(
      Dir.glob(File.join(Rails.root, 'app', 'models', '**', '*.rb')).
      detect {|f| File.read(f).any? {|l| l[/acts_as_event/]}},
    '.rb').classify rescue nil
  end
end

require 'eventable/acts_as_event'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dcs-eventable-0.0.8 lib/eventable.rb