Sha256: 33b4ed79a51b7d022c3d5c62e994b75acd38ff676fb021ff463e4096b7319ca4
Contents?: true
Size: 530 Bytes
Versions: 3
Compression:
Stored size: 530 Bytes
Contents
module Yema class Rule class Format < self attr_reader :format def initialize(attribute_name, options={}) super extract_options(options) end def self.required_options [:format] end def matches?(value) !!(format =~ value) end private def extract_options(options) @format = options.fetch(:format) raise InvalidOptionError, "Format option only accept Regexp" unless format.kind_of?(Regexp) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
yema-0.0.3 | lib/yema/rule/format.rb |
yema-0.0.2 | lib/yema/rule/format.rb |
yema-0.0.1 | lib/yema/rule/format.rb |