Module: ReputationSystem::Base

Defined in:
lib/reputation_system/base.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



19
20
21
# File 'lib/reputation_system/base.rb', line 19

def self.included(klass)
  klass.extend ClassMethods
end

Instance Method Details

#evaluate_reputation_scope(scope) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/reputation_system/base.rb', line 31

def evaluate_reputation_scope(scope)
  if scope
    if self.respond_to? scope
      self.send(scope)
    else
      scope
    end
  end
end

#get_attributes_of(reputation) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/reputation_system/base.rb', line 23

def get_attributes_of(reputation)
  of = reputation[:of]
  attrs = reputation[:of] == :self ? self : self.instance_eval(of.to_s) if of.is_a?(String) || of.is_a?(Symbol)
  attrs = self.instance_exec(self, &of) if of.is_a?(Proc)
  attrs = [attrs] unless attrs.is_a? Array
  attrs.compact
end