Class: InvalidRecordFinder::Finding
- Inherits:
-
Object
- Object
- InvalidRecordFinder::Finding
- Defined in:
- lib/invalid_record_finder/finding.rb
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#field_value ⇒ Object
readonly
Returns the value of attribute field_value.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(record, field, message) ⇒ Finding
constructor
A new instance of Finding.
- #to_a ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(record, field, message) ⇒ Finding
Returns a new instance of Finding.
6 7 8 9 10 11 12 13 |
# File 'lib/invalid_record_finder/finding.rb', line 6 def initialize(record, field, ) @model = record.class.name @field = field @field_value = record[field] @message = id = record[record.class.primary_key] @id = id.respond_to?(:tr) ? id.tr('-', '') : id end |
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
4 5 6 |
# File 'lib/invalid_record_finder/finding.rb', line 4 def field @field end |
#field_value ⇒ Object (readonly)
Returns the value of attribute field_value.
4 5 6 |
# File 'lib/invalid_record_finder/finding.rb', line 4 def field_value @field_value end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/invalid_record_finder/finding.rb', line 4 def id @id end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
4 5 6 |
# File 'lib/invalid_record_finder/finding.rb', line 4 def @message end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
4 5 6 |
# File 'lib/invalid_record_finder/finding.rb', line 4 def model @model end |
Instance Method Details
#==(other) ⇒ Object
23 24 25 |
# File 'lib/invalid_record_finder/finding.rb', line 23 def ==(other) other.is_a?(self.class) && other.to_h == to_h end |
#to_a ⇒ Object
15 16 17 |
# File 'lib/invalid_record_finder/finding.rb', line 15 def to_a [model, field, field_value, , id] end |
#to_h ⇒ Object
19 20 21 |
# File 'lib/invalid_record_finder/finding.rb', line 19 def to_h { model: model, field: field, field_value: field_value, message: , id: id } end |