class Checkability::StorageChecker

Checks if postcode exists in Storage

Attributes

attr_name[R]
storage_class[R]

Public Instance Methods

message(res, str = nil) click to toggle source
# File lib/checkability/storage_checker.rb, line 20
def message(res, str = nil)
  "#{res}:::Allowed #{storage_class}s list: #{str}"
end
post_initialize(conf = {}) click to toggle source
# File lib/checkability/storage_checker.rb, line 10
def post_initialize(conf = {})
  @storage_class = conf[:storage_class]
  @attr_name = conf[:attr_name] || :value
end
result(checkable) click to toggle source
# File lib/checkability/storage_checker.rb, line 15
def result(checkable)
  value = _normalize_value(checkable.send(attr_name))
  storage_class.where(attr_name => value).present?
end

Private Instance Methods

_normalize_value(value) click to toggle source
# File lib/checkability/storage_checker.rb, line 26
def _normalize_value(value)
  value.delete(' ').upcase
end