Class: Woody::Decorators::Challenge

Inherits:
Base
  • Object
show all
Defined in:
lib/woody/decorators/challenge.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize, #method_missing

Constructor Details

This class inherits a constructor from Woody::Decorators::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Woody::Decorators::Base

Instance Method Details

#brand_nameObject



7
8
9
# File 'lib/woody/decorators/challenge.rb', line 7

def brand_name
  brand.name
end

#reward_totalObject



11
12
13
14
15
# File 'lib/woody/decorators/challenge.rb', line 11

def reward_total
  @model.rewards.inject(0) do |total, reward|
    total + (reward.quantity * reward.amount)
  end
end

#statusObject



17
18
19
20
21
# File 'lib/woody/decorators/challenge.rb', line 17

def status
  return "Draft" if @model.status == "draft"
  return "Live" if DateTime.parse(@model.end_date) > DateTime.now
  purchased_videos > 0 ? "Complete" : "Video Review"
end