Sha256: b29d0eba36005e866ec9b0be08813a865d4c33769f8b675b659182ec0dca3f90
Contents?: true
Size: 558 Bytes
Versions: 3
Compression:
Stored size: 558 Bytes
Contents
module Yema class Rule class Inclusion < self attr_reader :within def initialize(attribute_name, options={}) super extract_options(options) end def self.required_options [:within] end def matches?(value) within.include?(value) end private def extract_options(options) @within = options.fetch(:within) raise InvalidOptionError, "Within option only accept Array or Range" unless [Array, Range].include?(within.class) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
yema-0.0.3 | lib/yema/rule/inclusion.rb |
yema-0.0.2 | lib/yema/rule/inclusion.rb |
yema-0.0.1 | lib/yema/rule/inclusion.rb |