Class: Greenenvy::NameValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/greenenvy/name_validator.rb

Instance Method Summary collapse

Constructor Details

#initialize(name_checker) ⇒ NameValidator

Returns a new instance of NameValidator.



3
4
5
# File 'lib/greenenvy/name_validator.rb', line 3

def initialize(name_checker)
  @name_checker = name_checker
end

Instance Method Details

#validate!(name) ⇒ Object



7
8
9
10
11
# File 'lib/greenenvy/name_validator.rb', line 7

def validate!(name)
  unless @name_checker.valid?(name)
    raise Exceptions::InvalidKey, "Invalid key, #{name}."
  end
end