Class: FormKeeper::Record

Inherits:
Object
  • Object
show all
Defined in:
lib/formkeeper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Record

Returns a new instance of Record.



418
419
420
421
422
# File 'lib/formkeeper.rb', line 418

def initialize(name)
  @name = name
  @value = nil
  @failed_constraints = []
end

Instance Attribute Details

#failed_constraintsObject (readonly)

Returns the value of attribute failed_constraints.



416
417
418
# File 'lib/formkeeper.rb', line 416

def failed_constraints
  @failed_constraints
end

#nameObject (readonly)

Returns the value of attribute name.



416
417
418
# File 'lib/formkeeper.rb', line 416

def name
  @name
end

#valueObject

Returns the value of attribute value.



417
418
419
# File 'lib/formkeeper.rb', line 417

def value
  @value
end

Instance Method Details

#fail(constraint) ⇒ Object



423
424
425
# File 'lib/formkeeper.rb', line 423

def fail(constraint)
  @failed_constraints << constraint
end

#failed?Boolean

Returns:

  • (Boolean)


426
427
428
# File 'lib/formkeeper.rb', line 426

def failed?
  @failed_constraints.size > 0
end

#failed_by?(constraint) ⇒ Boolean

Returns:

  • (Boolean)


429
430
431
# File 'lib/formkeeper.rb', line 429

def failed_by?(constraint)
  @failed_constraints.include?(constraint.to_sym)
end