Skip to content

Instantly share code, notes, and snippets.

@wdspkr
Created December 13, 2021 11:42
Show Gist options
  • Save wdspkr/2d1eb793307259f88fa69f0d29e5f559 to your computer and use it in GitHub Desktop.
Save wdspkr/2d1eb793307259f88fa69f0d29e5f559 to your computer and use it in GitHub Desktop.
module InterestRepository
def my_index
InterestCollection.new(InterestRecord.includes(:account).order(percentage: :desc).all)
end
end
class InterestCollection < Array
def initialize(record_array)
inital_array = record_array.map do |interest_data|
Interest.new(interest_data.attributes_with_associations)
end
super(initial_array)
end
def my_custom_collection_method
...
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment