Class: DepsGrapher::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/deps_grapher/event.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, const_name:, location:, method:) ⇒ Event

Returns a new instance of Event.



39
40
41
42
43
44
45
# File 'lib/deps_grapher/event.rb', line 39

def initialize(name:, const_name:, location:, method:)
  @name = name
  @const_name = const_name
  @location = location
  @method = method
  @skip_processing = false
end

Instance Attribute Details

#const_nameObject

Returns the value of attribute const_name.



37
38
39
# File 'lib/deps_grapher/event.rb', line 37

def const_name
  @const_name
end

#locationObject

Returns the value of attribute location.



37
38
39
# File 'lib/deps_grapher/event.rb', line 37

def location
  @location
end

#methodObject

Returns the value of attribute method.



37
38
39
# File 'lib/deps_grapher/event.rb', line 37

def method
  @method
end

#nameObject

Returns the value of attribute name.



37
38
39
# File 'lib/deps_grapher/event.rb', line 37

def name
  @name
end

Class Method Details

.add(name:, const_name:, location:, method: nil) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/deps_grapher/event.rb', line 15

def add(name:, const_name:, location:, method: nil)
  key = generate_key name, const_name, method

  return nil if key.nil?

  registry[key] ||= new(
    name: name,
    const_name: const_name,
    location: location,
    method: method
  )
end

.generate_key(name, const_name, method) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/deps_grapher/event.rb', line 6

def generate_key(name, const_name, method)
  return nil if const_name.nil? && method.nil?

  key = name.to_s.dup
  key << ".#{const_name}" if const_name
  key << ".#{method}" if method
  key
end

Instance Method Details

#keyObject



47
48
49
# File 'lib/deps_grapher/event.rb', line 47

def key
  self.class.generate_key name, const_name, method
end

#processing!Object



51
52
53
# File 'lib/deps_grapher/event.rb', line 51

def processing!
  @skip_processing = false
end

#processing?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/deps_grapher/event.rb', line 59

def processing?
  !@skip_processing
end

#skip_processing!Object



55
56
57
# File 'lib/deps_grapher/event.rb', line 55

def skip_processing!
  @skip_processing = true
end