Class: FormKeeper::Rule::Criteria::Combination
- Inherits:
-
Object
- Object
- FormKeeper::Rule::Criteria::Combination
- Defined in:
- lib/formkeeper.rb
Instance Attribute Summary collapse
-
#arg ⇒ Object
readonly
Returns the value of attribute arg.
-
#constraint ⇒ Object
readonly
Returns the value of attribute constraint.
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
Instance Method Summary collapse
-
#initialize(criteria) ⇒ Combination
constructor
A new instance of Combination.
Constructor Details
#initialize(criteria) ⇒ Combination
Returns a new instance of Combination.
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 |
# File 'lib/formkeeper.rb', line 605 def initialize(criteria) if criteria.has_key?(:fields) fields = criteria.delete(:fields) if fields.kind_of?(Array) && fields.size >= 2 @fields = fields.collect(&:to_sym) else raise ArgumentError.new("combination rule requires :fields as array which include 2 fields at lease") end else raise ArgumentError.new("combination rule requires :fields") end if criteria.has_key?(:filters) filters = criteria.delete :filters case filters when Array @filters = filters.collect(&:to_sym) when String @filters = [filters.to_sym] when Symbol @filters = [filters] else raise ArgumentError.new 'invalid :filters' end else @filters = [] end constraint = criteria.shift if constraint.nil? raise ArgumentError.new 'constraint not found' else @constraint = constraint[0] @arg = constraint[1] end end |
Instance Attribute Details
#arg ⇒ Object (readonly)
Returns the value of attribute arg.
604 605 606 |
# File 'lib/formkeeper.rb', line 604 def arg @arg end |
#constraint ⇒ Object (readonly)
Returns the value of attribute constraint.
604 605 606 |
# File 'lib/formkeeper.rb', line 604 def constraint @constraint end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
604 605 606 |
# File 'lib/formkeeper.rb', line 604 def fields @fields end |
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
604 605 606 |
# File 'lib/formkeeper.rb', line 604 def filters @filters end |