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
546 547 548 549 550 551 552 553 554 555 556 557 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 |
# File 'lib/formkeeper.rb', line 546 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.
545 546 547 |
# File 'lib/formkeeper.rb', line 545 def constraints @constraints end |
#count ⇒ Object (readonly)
Returns the value of attribute count.
545 546 547 |
# File 'lib/formkeeper.rb', line 545 def count @count end |
#default ⇒ Object (readonly)
Returns the value of attribute default.
545 546 547 |
# File 'lib/formkeeper.rb', line 545 def default @default end |
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
545 546 547 |
# File 'lib/formkeeper.rb', line 545 def filters @filters end |