Module: Rxhp::AttributeValidator::ClassMethods

Defined in:
lib/rxhp/attribute_validator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#acceptable_attributesObject

Returns the value of attribute acceptable_attributes


110
111
112
# File 'lib/rxhp/attribute_validator.rb', line 110

def acceptable_attributes
  @acceptable_attributes
end

#required_attributesObject

Returns the value of attribute required_attributes


110
111
112
# File 'lib/rxhp/attribute_validator.rb', line 110

def required_attributes
  @required_attributes
end

Instance Method Details

#accept_all_attributesObject

Accept any attributes whatsoever.


142
143
144
# File 'lib/rxhp/attribute_validator.rb', line 142

def accept_all_attributes
  accept_attributes Object
end

#accept_attributes(pattern) ⇒ Object Also known as: accept_attribute

Accept all attributes matching the specified pattern.

Examples:

accept_attribute 'id'
accept_attribute /^data-/
accept_attributes ['href', 'src']
accept_attributes ({ 'type' => ['checkbox', 'text', 'submit'] })

127
128
129
# File 'lib/rxhp/attribute_validator.rb', line 127

def accept_attributes pattern
  acceptable_attributes.push pattern
end

#require_attributes(pattern) ⇒ Object Also known as: require_attribute

Require an attribute matching the specified pattern.


135
136
137
138
# File 'lib/rxhp/attribute_validator.rb', line 135

def require_attributes pattern
  accept_attributes pattern
  required_attributes.push pattern
end