Sha256: 99be56fca75549b78ec1c13e553ff40dd023297eaf0306f8ed64ba9db6dcaf94

Contents?: true

Size: 752 Bytes

Versions: 1

Compression:

Stored size: 752 Bytes

Contents

require 'news_stand'

module NewsStand
  class Memory
    def initialize(options = {})
      @options = options
    end

    def all
      self.class.all
    end

    def get(number)
      self.class.get(number)
    end

    def set(attributes = {})
      self.class.set(attributes)
    end

    class << self
      def issues
        @issues ||= {}
      end

      def all
        issues.values
      end

      def get(key)
        issues[key]
      end

      def set(attributes)
        key = (attributes['number'] ||= next_key)
        issues[key] = attributes
      end

      def next_key
        issues.keys.length + 1
      end

      def reset
        issues.clear
      end
    end
  end
end

NewsStand.register(:memory, NewsStand::Memory)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
news_stand-0.1.1 lib/news_stand/memory.rb