I am trying to stay DRY in my otherwise damp code and I share some address methods between various classes that use address and I am trying to put them in a module but am not confident I am doing this right. Below is what I want to do but I am unsure about two things. first, will this work using address from the class including this module and second I am unsure where to add the ADDRESS_TYPES thingy.
module AddressModule
class << self
def delivery_address
where(address_type: ADDRESS_TYPES.delivery)
end
def billing_address
where(address_type: ADDRESS_TYPES.billing)
end
end
end
Third, does the above code makes sense at all when included in for example an account class?
I ended up with something much simpler…