Sha256: 3c647d21f119edb4291d525cf38aa48815af8bafc0c13d77a412843099b0b0f1

Contents?: true

Size: 559 Bytes

Versions: 3

Compression:

Stored size: 559 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 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.2.0 lib/rate_center/collection.rb
rate_center-0.1.7 lib/rate_center/collection.rb
rate_center-0.1.6 lib/rate_center/collection.rb