Sha256: d72a8cc8a5148b46222e85e6e02f6f9ac6f7603c5e894918d2aaaa3bbe2bf922
Contents?: true
Size: 706 Bytes
Versions: 2
Compression:
Stored size: 706 Bytes
Contents
module RateCenter module Collection def collection raise Errors::DataNotLoadedError.new("No data loaded. Load data with RateCenter.load before calling this method") if data.nil? @collection ||= load_collection end def reload! @collection = nil end def all collection end def where(attributes) collection.select do |element| attributes.all? { |key, value| element[key] == value } end end def find_by(attributes) collection.find do |element| attributes.all? { |key, value| element[key] == value } end end def find_by!(*) find_by(*) || raise(Errors::NotFoundError.new) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rate_center-0.3.1 | lib/rate_center/collection.rb |
rate_center-0.3.0 | lib/rate_center/collection.rb |