Class: Shokkenki::Provider::Session
- Inherits:
-
Object
- Object
- Shokkenki::Provider::Session
- Includes:
- Configuration::Session
- Defined in:
- lib/shokkenki/provider/session.rb
Instance Attribute Summary collapse
-
#providers ⇒ Object
readonly
Returns the value of attribute providers.
-
#ticket_location ⇒ Object
Returns the value of attribute ticket_location.
Instance Method Summary collapse
- #add_provider(provider) ⇒ Object
-
#initialize ⇒ Session
constructor
A new instance of Session.
- #redeem_tickets ⇒ Object
Methods included from Configuration::Session
#configure, #provider, #tickets
Constructor Details
#initialize ⇒ Session
Returns a new instance of Session.
13 14 15 16 17 |
# File 'lib/shokkenki/provider/session.rb', line 13 def initialize @ticket_reader = TicketReader.new @ticket_location = 'tickets' @providers = {}.with_indifferent_access end |
Instance Attribute Details
#providers ⇒ Object (readonly)
Returns the value of attribute providers.
11 12 13 |
# File 'lib/shokkenki/provider/session.rb', line 11 def providers @providers end |
#ticket_location ⇒ Object
Returns the value of attribute ticket_location.
10 11 12 |
# File 'lib/shokkenki/provider/session.rb', line 10 def ticket_location @ticket_location end |
Instance Method Details
#add_provider(provider) ⇒ Object
19 20 21 |
# File 'lib/shokkenki/provider/session.rb', line 19 def add_provider provider @providers[provider.name] = provider end |
#redeem_tickets ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/shokkenki/provider/session.rb', line 23 def redeem_tickets @ticket_reader.read_from(ticket_location).each do |ticket| provider = providers[ticket.provider.name] raise "No provider named '#{ticket.provider.name}' was found. Did you register one?" unless provider ticket.verify_with provider end end |