Sha256: 019d0643bfbc49f8ee0eab08dbc9779d57db1a0dfe507f443cc3c4cfd6ac6abb

Contents?: true

Size: 571 Bytes

Versions: 1

Compression:

Stored size: 571 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 = 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

1 entries across 1 versions & 1 rubygems

Version Path
rate_center-0.1.5 lib/rate_center/collection.rb