class LazyNames::ConfigValidator
Constants
- Errors
Attributes
constants[R]
errors[R]
lazy_names[R]
Public Class Methods
new(lazy_names, constants)
click to toggle source
# File lib/lazy_names/config_validator.rb, line 7 def initialize(lazy_names, constants) @errors = Errors.new([], []) @constants = constants @lazy_names = lazy_names end
Public Instance Methods
call()
click to toggle source
# File lib/lazy_names/config_validator.rb, line 13 def call validate_constants! validate_lazy_names! self end
Private Instance Methods
difference(arr, other)
click to toggle source
# File lib/lazy_names/config_validator.rb, line 49 def difference(arr, other) copy = arr.dup other.each do |e| i = copy.rindex(e) copy.delete_at(i) if i end copy end
resolve_const_in_project(const)
click to toggle source
# File lib/lazy_names/config_validator.rb, line 45 def resolve_const_in_project(const) Module.const_get(const) end
validate_constants!()
click to toggle source
# File lib/lazy_names/config_validator.rb, line 24 def validate_constants! constants.each do |c| begin resolve_const_in_project(c) rescue NameError self.errors.undefined << c end end end
validate_lazy_names!()
click to toggle source
# File lib/lazy_names/config_validator.rb, line 34 def validate_lazy_names! a = lazy_names.uniq b = lazy_names diff = difference(b, a) return unless diff diff.each { |name| self.errors.already_defined << name } end