Class: Aequitas::VirtusIntegration::InlineAttributeRuleExtractor::Array
- Inherits:
-
Object
- Object
- Object
- Aequitas::VirtusIntegration::InlineAttributeRuleExtractor::Array
- Defined in:
- lib/aequitas/virtus_integration/inline_attribute_rule_extractor/array.rb
Instance Attribute Summary
Attributes inherited from Object
Instance Method Summary collapse
Methods inherited from Object
#extract_presence_rule, #extract_primitive_type_rule, #initialize, #options
Constructor Details
This class inherits a constructor from Aequitas::VirtusIntegration::InlineAttributeRuleExtractor::Object
Instance Method Details
#extract ⇒ Object
10 11 12 13 |
# File 'lib/aequitas/virtus_integration/inline_attribute_rule_extractor/array.rb', line 10 def extract rules = super rules.concat Array(extract_length_rules) end |
#extract_length_rules ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/aequitas/virtus_integration/inline_attribute_rule_extractor/array.rb', line 15 def extract_length_rules length = .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 |