Sha256: 3184b8223d99ad10965be141ad1660444629c159404e4b32a0a2cefee24cc49b

Contents?: true

Size: 802 Bytes

Versions: 23

Compression:

Stored size: 802 Bytes

Contents

module Analytical
  class SessionCommandStore
    attr_reader :session, :module_key

    def initialize(session, module_key, initial_list=nil)
      @session = session
      @module_key = module_key
      @session_key = ('analytical_'+module_key.to_s).to_sym
      ensure_session_setup!(initial_list)
    end

    def assign(v)
      self.commands = v
    end

    def commands
      @session[@session_key]
    end
    def commands=(v)
      @session[@session_key] = v
    end

    def flush
      self.commands = []
    end

    # Pass any array methods on to the internal array
    def method_missing(method, *args, &block)
      commands.send(method, *args, &block)
    end

    private

    def ensure_session_setup!(initial_list=nil)
      self.commands ||= (initial_list || [])
    end

  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
analytical-3.0.12 lib/analytical/session_command_store.rb
analytical-3.0.11 lib/analytical/session_command_store.rb
analytical-3.0.9 lib/analytical/session_command_store.rb
analytical-3.0.8 lib/analytical/session_command_store.rb
analytical-3.0.7 lib/analytical/session_command_store.rb
analytical-3.0.6 lib/analytical/session_command_store.rb
gsiener-analytical-2.10.2 lib/analytical/session_command_store.rb
gsiener-analytical-2.10.1 lib/analytical/session_command_store.rb
analytical-2.11.0 lib/analytical/session_command_store.rb
analytical-2.10.0 lib/analytical/session_command_store.rb
gsiener-analytical-2.10.0 lib/analytical/session_command_store.rb
analytical-2.9.0 lib/analytical/session_command_store.rb
analytical-2.8.0 lib/analytical/session_command_store.rb
analytical-2.7.2 lib/analytical/session_command_store.rb
analytical-2.7.1 lib/analytical/session_command_store.rb
analytical-2.7.0 lib/analytical/session_command_store.rb
analytical-2.6.0 lib/analytical/session_command_store.rb
analytical-2.5.0 lib/analytical/session_command_store.rb
analytical-2.4.0 lib/analytical/session_command_store.rb
analytical-2.3.0 lib/analytical/session_command_store.rb