Module: Emotions

Defined in:
lib/emotions.rb,
lib/emotions/errors.rb,
lib/emotions/emotion.rb,
lib/emotions/emotive.rb,
lib/emotions/railtie.rb,
lib/emotions/version.rb,
lib/emotions/emotional.rb,
lib/generators/emotions/install_generator.rb

Defined Under Namespace

Modules: Emotion, Emotional, Emotive, Generators Classes: InvalidEmotion, Railtie

Constant Summary collapse

VERSION =
'0.3.1'

Class Method Summary collapse

Class Method Details

.configure {|@configuration| ... } ⇒ Object

Yields:

  • (@configuration)


11
12
13
14
# File 'lib/emotions.rb', line 11

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

.emotionsObject



16
17
18
# File 'lib/emotions.rb', line 16

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

.inject_into_active_recordObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/emotions.rb', line 20

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

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

    def self.acts_as_emotion
      send :include, Emotions::Emotion
    end

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

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