Sha256: a18896fa1cf1940b83e96f4d16496b160fe3dfa1e8d32be294c3281a06ca9647

Contents?: true

Size: 910 Bytes

Versions: 1

Compression:

Stored size: 910 Bytes

Contents

require 'emotions/version'

require 'ostruct'
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

1 entries across 1 versions & 1 rubygems

Version Path
emotions-0.2.2 lib/emotions.rb