Class: Holidays::Definition::Repository::CustomMethods

Inherits:
Object
  • Object
show all
Defined in:
lib/holidays/definition/repository/custom_methods.rb

Instance Method Summary collapse

Constructor Details

#initializeCustomMethods

Returns a new instance of CustomMethods.



5
6
7
# File 'lib/holidays/definition/repository/custom_methods.rb', line 5

def initialize
  @custom_methods = {}
end

Instance Method Details

#add(new_custom_methods) ⇒ Object

This performs a merge that overwrites any conflicts. While this is not ideal I’m leaving it as-is since I have no evidence of any current definitions that will cause an issue.

FIXME: this should probably return an error if a method with the same ID already exists.

Raises:

  • (ArgumentError)


15
16
17
18
# File 'lib/holidays/definition/repository/custom_methods.rb', line 15

def add(new_custom_methods)
  raise ArgumentError if new_custom_methods.nil?
  @custom_methods.merge!(new_custom_methods)
end

#find(method_id) ⇒ Object

Raises:

  • (ArgumentError)


20
21
22
23
# File 'lib/holidays/definition/repository/custom_methods.rb', line 20

def find(method_id)
  raise ArgumentError if method_id.nil? || method_id.empty?
  @custom_methods[method_id]
end