Class: OrigenTesters::Charz::Session

Inherits:
Profile
  • Object
show all
Defined in:
lib/origen_testers/charz/session.rb

Overview

A charz session contains the final combination of charz object (routines/profiles) and user options to determine how and what charz tests should be created the session should be checked in your interface to determine the current status and can be queried to make charz generation decisions

Instance Attribute Summary collapse

Attributes inherited from Profile

#charz_only, #enables, #flags, #id, #name, #on_result, #placement, #routines

Instance Method Summary collapse

Methods inherited from Profile

#attrs_ok?, #gate_check, #method_missing

Constructor Details

#initialize(options = {}) ⇒ Session

Returns a new instance of Session.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/origen_testers/charz/session.rb', line 11

def initialize(options = {})
  @id = :current_charz_session
  @active = false
  @valid = false
  if options[:defaults]
    @defaults = options[:defaults]
  else
    @defaults = {
      placement:  :inline,
      on_result:  nil,
      enables:    nil,
      flags:      nil,
      name:       'charz',
      charz_only: false
    }
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class OrigenTesters::Charz::Profile

Instance Attribute Details

#defaultsHash

Returns list of values to instantiate the inherited attributes from Profile with if not altered by the session update.

Returns:

  • (Hash)

    list of values to instantiate the inherited attributes from Profile with if not altered by the session update



9
10
11
# File 'lib/origen_testers/charz/session.rb', line 9

def defaults
  @defaults
end

Instance Method Details

#pauseObject

Pauses the current session’s activity while maintaining everthing else about the sessions state



30
31
32
# File 'lib/origen_testers/charz/session.rb', line 30

def pause
  @active = false
end

#resumeObject

Resume activity, if the session is valid



35
36
37
38
39
# File 'lib/origen_testers/charz/session.rb', line 35

def resume
  if @valid
    @active = true
  end
end

#update(charz_obj, options) ⇒ Object

Takes a Routine or Profile, and queries it to setup the session’s attributes the attributes values can be set from 3 different sources, in order of priority (first is most important):

- options
- charz object
- defaults

If the resulting session is invalid, @valid will turn false. Otherwise, the session becomes active



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/origen_testers/charz/session.rb', line 48

def update(charz_obj, options)
  @valid = false
  if charz_obj.nil?
    @active = false
    @valid = false
    return @valid
  end
  @defined_routines = options.delete(:defined_routines)
  assign_by_priority(:placement, charz_obj, options)
  assign_by_priority(:on_result, charz_obj, options)
  assign_by_priority(:enables, charz_obj, options)
  assign_by_priority(:flags, charz_obj, options)
  assign_by_priority(:routines, charz_obj, options)
  assign_by_priority(:name, charz_obj, options)
  assign_by_priority(:charz_only, charz_obj, options)
  attrs_ok?
  massage_gates
  @active = true
  @valid = true
end