Module: Kudos::ClassMethods

Defined in:
lib/kudos.rb

Instance Method Summary collapse

Instance Method Details

#award(award_name, *attributes) ⇒ Object



38
39
40
41
# File 'lib/kudos.rb', line 38

def award(award_name, *attributes)
  achievements = Kudos::Achievement.where(award_name: award_name.to_s).order(rank: :asc)
  configuration.achievements_model_name.awards[award_name].call(achievements, *attributes)
end

#award_for(award_name, &block) ⇒ Object



34
35
36
# File 'lib/kudos.rb', line 34

def award_for(award_name, &block)
  awards[award_name] = block
end

#awardsObject



30
31
32
# File 'lib/kudos.rb', line 30

def awards
  @awards ||= {}
end

#configurationObject

Public: Returns Kudos::Configuration instance.



26
27
28
# File 'lib/kudos.rb', line 26

def configuration
  @configuration ||= Configuration.new
end

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

Public: Configure kudos.

Kudos.configure do |config|
  config.achievements_model_name = ::Achievement
end

Yields:



21
22
23
# File 'lib/kudos.rb', line 21

def configure
  yield configuration
end