Class: Eventify

Inherits:
Object
  • Object
show all
Defined in:
lib/eventify.rb,
lib/eventify/version.rb,
lib/eventify/provider/base.rb

Defined Under Namespace

Modules: Provider Classes: Configuration, Database, Mail

Constant Summary collapse

VERSION =
"1.2.2"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration = Eventify::Configuration.new) ⇒ Eventify

Returns a new instance of Eventify.



14
15
16
# File 'lib/eventify.rb', line 14

def initialize(configuration=Eventify::Configuration.new)
  @configuration = configuration
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



12
13
14
# File 'lib/eventify.rb', line 12

def configuration
  @configuration
end

#providersObject



36
37
38
39
40
41
42
43
# File 'lib/eventify.rb', line 36

def providers
  @providers ||= [
    Eventify::Provider::Piletilevi,
    Eventify::Provider::Ticketpro,
    Eventify::Provider::FBI,
    Eventify::Provider::SolarisKino
  ]
end

Instance Method Details

#all_eventsObject



18
19
20
# File 'lib/eventify.rb', line 18

def all_events
  @all_events ||= providers.flat_map(&:fetch).uniq
end

#new_eventsObject



22
23
24
# File 'lib/eventify.rb', line 22

def new_events
  @new_events ||= all_events.reject(&:exists?)
end

#process_new_eventsObject



26
27
28
29
30
31
32
# File 'lib/eventify.rb', line 26

def process_new_events
  all_new_events = new_events
  return if all_new_events.empty?

  Eventify::Mail.deliver all_new_events, @configuration
  all_new_events.each(&:save)
end