Class: Aequitas::VirtusIntegration::InlineAttributeRuleExtractor::String
- Inherits:
-
Object
- Object
- Object
- Aequitas::VirtusIntegration::InlineAttributeRuleExtractor::String
show all
- Defined in:
- lib/aequitas/virtus_integration/inline_attribute_rule_extractor/string.rb
Instance Attribute Summary
Attributes inherited from Object
#attribute
Instance Method Summary
collapse
Methods inherited from Object
#extract_presence_rule, #extract_primitive_type_rule, #initialize, #options
Instance Method Details
10
11
12
13
14
|
# File 'lib/aequitas/virtus_integration/inline_attribute_rule_extractor/string.rb', line 10
def
rules = super
rules.concat(Array())
rules.concat(Array())
end
|
27
28
29
30
|
# File 'lib/aequitas/virtus_integration/inline_attribute_rule_extractor/string.rb', line 27
def
format = options.fetch(:format, false)
Rule::Format.rules_for(attribute.name, :with => format) if format
end
|
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/aequitas/virtus_integration/inline_attribute_rule_extractor/string.rb', line 16
def
length = options.fetch(:length, false)
case length
when ::Integer; Rule::Length::Equal.new(attribute.name, :expected => length)
when ::Range; Rule::Length::Range.new(attribute.name, :range => length)
when ::FalseClass;
else raise ArgumentError, "expected Integer or Range :length, got: #{length.inspect}"
end
end
|