Class: Break::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/break/session.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(binding, frontend:) ⇒ Session

Returns a new instance of Session.



8
9
10
11
12
# File 'lib/break/session.rb', line 8

def initialize(binding, frontend:)
  @contexts = [Context.new(binding)]
  @frontend = frontend
  @metadata = {}
end

Instance Attribute Details

#contextsObject (readonly)

Returns the value of attribute contexts.



5
6
7
# File 'lib/break/session.rb', line 5

def contexts
  @contexts
end

#frontendObject (readonly)

Returns the value of attribute frontend.



6
7
8
# File 'lib/break/session.rb', line 6

def frontend
  @frontend
end

Instance Method Details

#[](key) ⇒ Object



31
32
33
# File 'lib/break/session.rb', line 31

def [](key)
  @metadata[key]
end

#[]=(key, value) ⇒ Object



35
36
37
# File 'lib/break/session.rb', line 35

def []=(key, value)
  @metadata[key] = value
end

#contextObject



22
23
24
# File 'lib/break/session.rb', line 22

def context
  contexts.last
end

#context!(*bindings, depth: 0) ⇒ Object



26
27
28
29
# File 'lib/break/session.rb', line 26

def context!(*bindings, depth: 0)
  contexts << Context.new(*bindings, depth: depth)
  enter
end

#enterObject



14
15
16
# File 'lib/break/session.rb', line 14

def enter
  frontend.attach(self)
end

#leaveObject



18
19
20
# File 'lib/break/session.rb', line 18

def leave
  frontend.detach
end