Class: Stratagem::Model::Component::Reference

Inherits:
Object
  • Object
show all
Defined in:
lib/stratagem/model/components/reference.rb

Constant Summary collapse

EQUALITY_ATTRS =
[:reference_type, :from_component, :to_component, :line_number, :method, :function]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Reference

Returns a new instance of Reference.



9
10
11
# File 'lib/stratagem/model/components/reference.rb', line 9

def initialize(args={})
  args.each {|key,val| self.send("#{key}=", val) }
end

Instance Attribute Details

#from_componentObject

Returns the value of attribute from_component.



4
5
6
# File 'lib/stratagem/model/components/reference.rb', line 4

def from_component
  @from_component
end

#functionObject

Returns the value of attribute function.



5
6
7
# File 'lib/stratagem/model/components/reference.rb', line 5

def function
  @function
end

#line_numberObject

Returns the value of attribute line_number.



5
6
7
# File 'lib/stratagem/model/components/reference.rb', line 5

def line_number
  @line_number
end

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'lib/stratagem/model/components/reference.rb', line 5

def options
  @options
end

#reference_typeObject

:read, :write



3
4
5
# File 'lib/stratagem/model/components/reference.rb', line 3

def reference_type
  @reference_type
end

#request_methodObject

Returns the value of attribute request_method.



5
6
7
# File 'lib/stratagem/model/components/reference.rb', line 5

def request_method
  @request_method
end

#stack_traceObject

Returns the value of attribute stack_trace.



5
6
7
# File 'lib/stratagem/model/components/reference.rb', line 5

def stack_trace
  @stack_trace
end

#to_componentObject

Returns the value of attribute to_component.



4
5
6
# File 'lib/stratagem/model/components/reference.rb', line 4

def to_component
  @to_component
end

Instance Method Details

#==(other) ⇒ Object



13
14
15
# File 'lib/stratagem/model/components/reference.rb', line 13

def ==(other)
  eql?(other)
end

#compressed_stack_traceObject



37
38
39
40
41
42
43
# File 'lib/stratagem/model/components/reference.rb', line 37

def compressed_stack_trace
  if (stack_trace)
    TraceDeflator.deflate(stack_trace)
  else
    nil
  end
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
21
# File 'lib/stratagem/model/components/reference.rb', line 17

def eql?(other)
  EQUALITY_ATTRS.find {|attribute|
    self.send(attribute) != other.send(attribute) 
  }.nil?
end

#exportObject



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/stratagem/model/components/reference.rb', line 23

def export
  h = {
    :external_id => self.object_id,
    :reference_type => reference_type,
    :from_component_external_id => from_component ? from_component.object_id : nil,
    :to_component_external_id => to_component ? to_component.object_id : nil,
    :line_number => line_number,
    :request_method => request_method,
    :function => function,
    :options => options ? options.to_json : nil,
    :stack_trace => reference_type == :write ? compressed_stack_trace : nil
  }
end