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.



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_constraintsObject (readonly)

Returns the value of attribute failed_constraints.



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

def failed_constraints
  @failed_constraints
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#valueObject

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

Returns:

  • (Boolean)


433
434
435
# File 'lib/formkeeper.rb', line 433

def failed?
  @failed_constraints.size > 0
end

#failed_by?(constraint) ⇒ Boolean

Returns:

  • (Boolean)


436
437
438
# File 'lib/formkeeper.rb', line 436

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