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

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

Instance Method Summary collapse

Methods inherited from Profile

#attrs_ok?, #gate_check, #gate_check_and, #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
28
# 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,
      enables_and: 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



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

def pause
  @active = false
end

#resumeObject

Resume activity, if the session is valid



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

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



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/origen_testers/charz/session.rb', line 49

def update(charz_obj, options)
  @valid = false
  if charz_obj.nil?
    @active = false
    @valid = false
    return @valid
  end
  @defined_routines = options.delete(:defined_routines)

  if charz_obj.and_flags
    @and_flags = charz_obj.and_flags
  else
    @and_flags = false
  end
  if charz_obj.and_enables
    @and_enables = charz_obj.and_enables
  else
    @and_enables = false
  end
  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