Class: FormKeeper::Rule::Criteria::Checkbox
- Inherits:
-
Object
- Object
- FormKeeper::Rule::Criteria::Checkbox
- Defined in:
- lib/formkeeper.rb
Instance Attribute Summary collapse
-
#constraints ⇒ Object
readonly
Returns the value of attribute constraints.
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
Instance Method Summary collapse
-
#initialize(criteria) ⇒ Checkbox
constructor
A new instance of Checkbox.
Constructor Details
#initialize(criteria) ⇒ Checkbox
Returns a new instance of Checkbox.
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 |
# File 'lib/formkeeper.rb', line 558 def initialize(criteria) if criteria.has_key?(:default) default = criteria.delete :default case default when Array @default = default.collect(&:to_s) else @default = [default.to_s] end else @default = [] 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 if criteria.has_key?(:count) count = criteria.delete :count case count when Fixnum @count = Range.new(count, count) when Range @count = count else raise ArgumentError.new 'invalid :count' end else @count = nil end @constraints = criteria end |
Instance Attribute Details
#constraints ⇒ Object (readonly)
Returns the value of attribute constraints.
557 558 559 |
# File 'lib/formkeeper.rb', line 557 def constraints @constraints end |
#count ⇒ Object (readonly)
Returns the value of attribute count.
557 558 559 |
# File 'lib/formkeeper.rb', line 557 def count @count end |
#default ⇒ Object (readonly)
Returns the value of attribute default.
557 558 559 |
# File 'lib/formkeeper.rb', line 557 def default @default end |
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
557 558 559 |
# File 'lib/formkeeper.rb', line 557 def filters @filters end |