Module: Availability::FactoryMethods

Included in:
Availability, AbstractAvailability
Defined in:
lib/availability/factory_methods.rb

Instance Method Summary collapse

Instance Method Details

#create(**args) ⇒ Object

Raises:

  • (ArgumentError)


3
4
5
6
7
# File 'lib/availability/factory_methods.rb', line 3

def create(**args)
  cls = args.delete(:event_class) || Availability::subclass_for(args.delete(:frequency) || :daily)
  raise ArgumentError, "undefined frequency" if cls.nil?
  cls.send :new, **args
end

#once(**args) ⇒ Object



9
10
11
# File 'lib/availability/factory_methods.rb', line 9

def once(**args)
  Once.create **args
end