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: Emotional, Emotive, Generators Classes: Emotion, InvalidEmotion, Railtie

Constant Summary collapse

VERSION =
'0.2.1'

Class Method Summary collapse

Class Method Details

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

Yields:

  • (@configuration)


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

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

.emotionsObject



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

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

.inject_into_active_recordObject



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

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