Sha256: d1c10373b62c874954d9f9788ab41687cd5c110377d2b9c2018ee37dd6cd9aa4

Contents?: true

Size: 566 Bytes

Versions: 6

Compression:

Stored size: 566 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.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

6 entries across 6 versions & 1 rubygems

Version Path
simplestate-2.0.8 lib/simplestate/state.rb
simplestate-2.0.7 lib/simplestate/state.rb
simplestate-2.0.6 lib/simplestate/state.rb
simplestate-2.0.5 lib/simplestate/state.rb
simplestate-2.0.4 lib/simplestate/state.rb
simplestate-2.0.3 lib/simplestate/state.rb