Class: Yema::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/yema/rule.rb,
lib/yema/rule/format.rb,
lib/yema/rule/length.rb,
lib/yema/rule/required.rb,
lib/yema/rule/inclusion.rb,
lib/yema/rule/strong_type.rb

Direct Known Subclasses

Format, Inclusion, Length, Required, StrongType

Defined Under Namespace

Classes: Format, Inclusion, Length, Required, StrongType

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Rule.



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

def initialize(attribute_name, options={})
  assert_required_options(options)
  @attribute_name = attribute_name
end

Instance Attribute Details

#attribute_nameObject (readonly)

Returns the value of attribute attribute_name.



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

def attribute_name
  @attribute_name
end

Class Method Details

.required_optionsObject



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

def self.required_options
  []
end

Instance Method Details

#errors(resource) ⇒ Object



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

def errors(resource)
  Validator.new(resource, self).errors
end