Sha256: ae91d9fb6eae332f33b5d8c3495da35908ec042ac39dd69ca210746d175fda1d

Contents?: true

Size: 955 Bytes

Versions: 3

Compression:

Stored size: 955 Bytes

Contents

# frozen string_literal: true

require 'dry-struct'
require 'spy_alley_application/types/board_space'

module SpyAlleyApplication
  module Models
    module BoardSpaces
      class Start < Dry::Struct
        @@can_handle_start = ::Types.Interface(:handle_start)
        def self.new(id:, next_space: nil, &block)
          o = Start.allocate
          next_space ||= yield(o)
          o.send(:initialize, **{id: id, next_space: next_space})
          o
        end

        def initialize(id:, next_space: nil, &block)
          @id = ::Types::Coercible::Integer.call(id)
          @next_space = SpyAlleyApplication::Types::BoardSpace.call(next_space)
        end

        def id;@id;end
        def next_space;@next_space;end
        def in_spy_alley?;false;end
        def to_h;{id: id};end

        def accept(visitor, **args)
          @@can_handle_start.(visitor)
          visitor.handle_start(self, args)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spy_alley_application-0.3.2 lib/spy_alley_application/models/board_spaces/start.rb
spy_alley_application-0.3.1 lib/spy_alley_application/models/board_spaces/start.rb
spy_alley_application-0.3.0 lib/spy_alley_application/models/board_spaces/start.rb