Sha256: 4202fe2685d20cbbf76082b83305b0c3511d67a466f0e2c1479e2544c8fcf492

Contents?: true

Size: 892 Bytes

Versions: 2

Compression:

Stored size: 892 Bytes

Contents

require 'emotions/version'

require 'active_record'
require 'emotions/errors'
require 'emotions/emotion'
require 'emotions/emotive'
require 'emotions/emotional'

module Emotions
  def self.configure
    @configuration = OpenStruct.new
    yield(@configuration)
  end

  def self.emotions
    @configuration.emotions ||= []
  end

  def self.inject_into_active_record
    @inject_into_active_record ||= Proc.new do
      def self.acts_as_emotive
        self.send :include, Emotions::Emotive
      end

      def self.acts_as_emotional
        self.send :include, Emotions::Emotional
      end

      def self.emotional?
        @emotional ||= self.ancestors.include?(Emotions::Emotional)
      end

      def self.emotive?
        @emotive ||= self.ancestors.include?(Emotions::Emotive)
      end
    end
  end
end

require 'emotions/railtie' if defined?(Rails) && Rails::VERSION::MAJOR >= 3

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
emotions-0.2.1 lib/emotions.rb
emotions-0.2 lib/emotions.rb