Sha256: 131ccc82430f40337a14c9d327b096f97701111c355d8fe4af401797074a2358

Contents?: true

Size: 576 Bytes

Versions: 3

Compression:

Stored size: 576 Bytes

Contents

class State
  attr_reader :holder
  def initialize(holder:, opts: {})
    @holder = holder
    @holder.__send__(:add_state, self)
  end

  def name
    'State'
  end
  alias :to_s :name

  def symbol
    name.to_sym
  end

  private
    def transition_to(state)
      holder.__send__ :transition_to, state
    end

    def enter
      raise NotImplementedError, "#enter was called on an instance of State either directly or via super."
    end

    def exit
      raise NotImplementedError, "#exit was called on an instance of State either directly or via super."
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
simplestate-2.0.11 lib/simplestate/state.rb
simplestate-2.0.10 lib/simplestate/state.rb
simplestate-2.0.9 lib/simplestate/state.rb