Class: FormKeeper::Record
- Inherits:
-
Object
- Object
- FormKeeper::Record
- Defined in:
- lib/formkeeper.rb
Instance Attribute Summary collapse
-
#failed_constraints ⇒ Object
readonly
Returns the value of attribute failed_constraints.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #fail(constraint) ⇒ Object
- #failed? ⇒ Boolean
- #failed_by?(constraint) ⇒ Boolean
-
#initialize(name) ⇒ Record
constructor
A new instance of Record.
Constructor Details
#initialize(name) ⇒ Record
Returns a new instance of Record.
425 426 427 428 429 |
# File 'lib/formkeeper.rb', line 425 def initialize(name) @name = name @value = nil @failed_constraints = [] end |
Instance Attribute Details
#failed_constraints ⇒ Object (readonly)
Returns the value of attribute failed_constraints.
423 424 425 |
# File 'lib/formkeeper.rb', line 423 def failed_constraints @failed_constraints end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
423 424 425 |
# File 'lib/formkeeper.rb', line 423 def name @name end |
#value ⇒ Object
Returns the value of attribute value.
424 425 426 |
# File 'lib/formkeeper.rb', line 424 def value @value end |
Instance Method Details
#fail(constraint) ⇒ Object
430 431 432 |
# File 'lib/formkeeper.rb', line 430 def fail(constraint) @failed_constraints << constraint end |
#failed? ⇒ Boolean
433 434 435 |
# File 'lib/formkeeper.rb', line 433 def failed? @failed_constraints.size > 0 end |
#failed_by?(constraint) ⇒ Boolean
436 437 438 |
# File 'lib/formkeeper.rb', line 436 def failed_by?(constraint) @failed_constraints.include?(constraint.to_sym) end |