Class: Analytical::SessionCommandStore

Inherits:
Object
  • Object
show all
Defined in:
lib/analytical/session_command_store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session, module_key, initial_list = nil) ⇒ SessionCommandStore

Returns a new instance of SessionCommandStore.



5
6
7
8
9
10
# File 'lib/analytical/session_command_store.rb', line 5

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object

Pass any array methods on to the internal array



28
29
30
# File 'lib/analytical/session_command_store.rb', line 28

def method_missing(method, *args, &block)
  commands.send(method, *args, &block)
end

Instance Attribute Details

#module_keyObject (readonly)

Returns the value of attribute module_key.



3
4
5
# File 'lib/analytical/session_command_store.rb', line 3

def module_key
  @module_key
end

#sessionObject (readonly)

Returns the value of attribute session.



3
4
5
# File 'lib/analytical/session_command_store.rb', line 3

def session
  @session
end

Instance Method Details

#assign(v) ⇒ Object



12
13
14
# File 'lib/analytical/session_command_store.rb', line 12

def assign(v)
  self.commands = v
end

#commandsObject



16
17
18
# File 'lib/analytical/session_command_store.rb', line 16

def commands
  @session[@session_key]
end

#commands=(v) ⇒ Object



19
20
21
# File 'lib/analytical/session_command_store.rb', line 19

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

#flushObject



23
24
25
# File 'lib/analytical/session_command_store.rb', line 23

def flush
  self.commands = []
end