Module: Easyop::Plugins::Recording::ClassMethods

Defined in:
lib/easyop/plugins/recording.rb

Instance Method Summary collapse

Instance Method Details

#_recording_enabled?Boolean

Returns:

  • (Boolean)


66
67
68
69
# File 'lib/easyop/plugins/recording.rb', line 66

def _recording_enabled?
  return @_recording_enabled if instance_variable_defined?(:@_recording_enabled)
  superclass.respond_to?(:_recording_enabled?) ? superclass._recording_enabled? : true
end

#_recording_modelObject



71
72
73
74
# File 'lib/easyop/plugins/recording.rb', line 71

def _recording_model
  @_recording_model ||
    (superclass.respond_to?(:_recording_model) ? superclass._recording_model : nil)
end

#_recording_record_params?Boolean

Returns:

  • (Boolean)


76
77
78
79
80
81
82
83
84
# File 'lib/easyop/plugins/recording.rb', line 76

def _recording_record_params?
  if instance_variable_defined?(:@_recording_record_params)
    @_recording_record_params
  elsif superclass.respond_to?(:_recording_record_params?)
    superclass._recording_record_params?
  else
    true
  end
end

#_recording_record_result_configObject



103
104
105
106
107
108
109
110
111
# File 'lib/easyop/plugins/recording.rb', line 103

def _recording_record_result_config
  if instance_variable_defined?(:@_recording_record_result)
    @_recording_record_result
  elsif superclass.respond_to?(:_recording_record_result_config)
    superclass._recording_record_result_config
  else
    nil
  end
end

#record_result(value = nil, attrs: nil, &block) ⇒ Object

DSL for capturing result data after the operation runs. Three forms:

record_result attrs: :key           # one or more ctx keys
record_result { |ctx| { k: ctx.k } } # block
record_result :build_result         # private instance method name


91
92
93
94
95
96
97
98
99
100
101
# File 'lib/easyop/plugins/recording.rb', line 91

def record_result(value = nil, attrs: nil, &block)
  @_recording_record_result = if block
    block
  elsif attrs
    { attrs: attrs }
  elsif value.is_a?(Symbol)
    value
  else
    value
  end
end

#recording(enabled) ⇒ Object

Disable recording for this class: ‘recording false`



62
63
64
# File 'lib/easyop/plugins/recording.rb', line 62

def recording(enabled)
  @_recording_enabled = enabled
end