Class: Yema::Rule::Inclusion

Inherits:
Yema::Rule show all
Defined in:
lib/yema/rule/inclusion.rb

Instance Attribute Summary collapse

Attributes inherited from Yema::Rule

#attribute_name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Yema::Rule

#errors

Constructor Details

#initialize(attribute_name, options = {}) ⇒ Inclusion

Returns a new instance of Inclusion.



7
8
9
10
# File 'lib/yema/rule/inclusion.rb', line 7

def initialize(attribute_name, options={})
  super
  extract_options(options)
end

Instance Attribute Details

#withinObject (readonly)

Returns the value of attribute within.



5
6
7
# File 'lib/yema/rule/inclusion.rb', line 5

def within
  @within
end

Class Method Details

.required_optionsObject



12
13
14
# File 'lib/yema/rule/inclusion.rb', line 12

def self.required_options
  [:within]
end

Instance Method Details

#matches?(value) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/yema/rule/inclusion.rb', line 16

def matches?(value)
  within.include?(value)
end