Class: Changeset
Instance Attribute Summary collapse
-
#changes ⇒ Object
readonly
Returns the value of attribute changes.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize(params) ⇒ Changeset
constructor
A new instance of Changeset.
- #valid? ⇒ Boolean
Methods included from Validators
#cast, #validate_acceptance, #validate_change, #validate_confirmation, #validate_exclusion, #validate_format, #validate_inclusion, #validate_length, #validate_number, #validate_required, #validate_subset
Constructor Details
#initialize(params) ⇒ Changeset
Returns a new instance of Changeset.
9 10 11 12 13 14 15 |
# File 'lib/changeset.rb', line 9 def initialize(params) @changes = symbolized_keys(params) @errors = {} @changes.keys.each do |k| @errors[k] = {} end end |
Instance Attribute Details
#changes ⇒ Object (readonly)
Returns the value of attribute changes.
8 9 10 |
# File 'lib/changeset.rb', line 8 def changes @changes end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
8 9 10 |
# File 'lib/changeset.rb', line 8 def errors @errors end |
Instance Method Details
#valid? ⇒ Boolean
17 18 19 |
# File 'lib/changeset.rb', line 17 def valid? @errors.values.all?(&:empty?) end |