Module: RailsSettlement

Extended by:
ActiveSupport::Concern
Defined in:
lib/rails_settlement.rb,
lib/rails_settlement/version.rb

Constant Summary collapse

SETTABLE_REGEX =
/\Aset_(?<object>[a-z_]+)(?<raisable>!?)\z/.freeze
VERSION =
"1.5.0"

Instance Method Summary collapse

Instance Method Details

#_rs_associated_scope(scoped_relation:, associated_to: nil) ⇒ Object



69
70
71
72
73
# File 'lib/rails_settlement.rb', line 69

def _rs_associated_scope(scoped_relation:, associated_to: nil)
  return scoped_relation if associated_to.blank?

  scoped_relation.joins(associated_to).where(associated_to => public_send(associated_to))
end

#_rs_raise_record_not_found!(klass:, key:, id:) ⇒ Object

Raises:

  • (ActiveRecord::RecordNotFound)


75
76
77
# File 'lib/rails_settlement.rb', line 75

def _rs_raise_record_not_found!(klass:, key:, id:)
  raise ActiveRecord::RecordNotFound.new("Couldn't find #{klass} with '#{key}'='#{id}'", klass.name, key, Array.wrap(id))
end