Sha256: b4fdee9420523978f1f1bf433d1b0ecb3db13091d621311dda9cfbedcb1777ff

Contents?: true

Size: 510 Bytes

Versions: 3

Compression:

Stored size: 510 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 all
      collection
    end

    def find_by(attributes)
      collection.find do |region|
        attributes.all? { |key, value| region[key] == value }
      end
    end

    def find_by!(*)
      find_by(*) || raise(Errors::NotFoundError.new)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rate_center-0.1.4 lib/rate_center/collection.rb
rate_center-0.1.3 lib/rate_center/collection.rb
rate_center-0.1.2 lib/rate_center/collection.rb