Module: Persisted::RecordFinder
- Included in:
- Persisted
- Defined in:
- lib/persisted/record_finder.rb
Instance Method Summary collapse
Instance Method Details
#attributes_for_finding ⇒ Object
7 8 9 10 11 |
# File 'lib/persisted/record_finder.rb', line 7 def attributes_for_finding shared_attrs = self.class.instance_variable_get '@shared_attributes' shared_attrs.each_with_object({}){ |k, a| a[k] = @params[k] } end |
#existing_record ⇒ Object
13 14 15 |
# File 'lib/persisted/record_finder.rb', line 13 def existing_record self.class.send(:persisted_record_class).where( attributes_for_finding ).first end |
#persisted_record ⇒ Object
3 4 5 |
# File 'lib/persisted/record_finder.rb', line 3 def persisted_record @persisted_record ||= existing_record end |