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

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

Instance Method Summary collapse

Instance Method Details

#_recording_enabled?Boolean

Returns:

  • (Boolean)


69
70
71
72
# File 'lib/easyop/plugins/recording.rb', line 69

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

#_recording_modelObject



74
75
76
77
# File 'lib/easyop/plugins/recording.rb', line 74

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

#_recording_record_params?Boolean

Returns:

  • (Boolean)


79
80
81
82
83
84
85
86
87
# File 'lib/easyop/plugins/recording.rb', line 79

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



106
107
108
109
110
111
112
113
114
# File 'lib/easyop/plugins/recording.rb', line 106

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

#_recording_scrub_keysObject

Returns the merged scrub list: parent class keys + this class’s own keys. Does NOT include SCRUBBED_KEYS or the global config list — those are merged at persist time so they stay hot-reloadable.



131
132
133
134
# File 'lib/easyop/plugins/recording.rb', line 131

def _recording_scrub_keys
  parent = superclass.respond_to?(:_recording_scrub_keys) ? superclass._recording_scrub_keys : []
  parent + _own_recording_scrub_keys
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


94
95
96
97
98
99
100
101
102
103
104
# File 'lib/easyop/plugins/recording.rb', line 94

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`



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

def recording(enabled)
  @_recording_enabled = enabled
end

#scrub_params(*keys) ⇒ Object

DSL to declare additional keys/patterns to scrub from params_data. Accepts Symbol, String, or Regexp. Additive with SCRUBBED_KEYS and any scrub_keys declared on parent classes or at the plugin install level.

Examples:

class ApplicationOperation < ...
  scrub_params :api_token, /access.?key/i
end


124
125
126
# File 'lib/easyop/plugins/recording.rb', line 124

def scrub_params(*keys)
  @_recording_scrub_keys = _own_recording_scrub_keys + keys
end