Sha256: 6be476a08da5d3aaca1138c6208241d174da88b9f015888f859afc7f279067aa

Contents?: true

Size: 531 Bytes

Versions: 7

Compression:

Stored size: 531 Bytes

Contents

module Bioshogi
  extend ActiveSupport::Concern

  concern :ApplicationMemoryRecord do
    included do
      include MemoryRecord

      def self.fetch(*)
        super
      rescue KeyError => error
        raise KeyNotFound, error.message
      end

      # fetch できなかったとき default_key が指すレコードを返す
      def self.safe_fetch(key)
        v = lookup(key)
        unless v
          v = fetch(default_key)
        end
        v
      end
    end

    def inspect
      "<#{key}>"
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bioshogi-0.0.10 lib/bioshogi/application_memory_record.rb
bioshogi-0.0.9 lib/bioshogi/application_memory_record.rb
bioshogi-0.0.8 lib/bioshogi/application_memory_record.rb
bioshogi-0.0.7 lib/bioshogi/application_memory_record.rb
bioshogi-0.0.5 lib/bioshogi/application_memory_record.rb
bioshogi-0.0.4 lib/bioshogi/application_memory_record.rb
bioshogi-0.0.3 lib/bioshogi/application_memory_record.rb