Class: InertRecorder
Overview
Inert recorder is similar to a null object in the sense, that in response to almost all messages it returns self. But in addition, it records received messages along with their arguments and blocks (if given). Recoded messages are available via #recorded_messages reader, aliased #ρ (small Greek rho). Inert recorder does not require any arguments for initalization, but if they are supplied, they are silently recoded into @init_args (for arguments) and readers.
Instance Attribute Summary collapse
-
#init_args ⇒ Object
readonly
Returns the value of attribute init_args.
-
#init_block ⇒ Object
readonly
Returns the value of attribute init_block.
-
#recorded_messages ⇒ Object
(also: #ρ)
readonly
Returns the value of attribute recorded_messages.
Instance Method Summary collapse
-
#blank? ⇒ Boolean
Always false.
-
#initialize(*args, &block) ⇒ InertRecorder
constructor
No arguments are required for initialization, but if they are supplied, they are silently recorded into @init_args (for argument array) and @init_block (for block, if given) instance variables, exposed via standard readers.
-
#method_missing(ß, *args, &block) ⇒ Object
:nodoc:.
-
#present? ⇒ Boolean
Always true.
-
#respond_to?(ß, *args, &block) ⇒ Boolean
Always true.
Constructor Details
#initialize(*args, &block) ⇒ InertRecorder
No arguments are required for initialization, but if they are supplied, they are silently recorded into @init_args (for argument array) and @init_block (for block, if given) instance variables, exposed via standard readers.
22 23 24 25 26 |
# File 'lib/y_support/misc/inert_recorder.rb', line 22 def initialize *args, &block @init_args = args @init_block = block @recorded_messages = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(ß, *args, &block) ⇒ Object
:nodoc:
40 41 42 43 |
# File 'lib/y_support/misc/inert_recorder.rb', line 40 def method_missing ß, *args, &block # :nodoc: @recorded_messages << [ ß, args, block ] return self end |
Instance Attribute Details
#init_args ⇒ Object (readonly)
Returns the value of attribute init_args.
15 16 17 |
# File 'lib/y_support/misc/inert_recorder.rb', line 15 def init_args @init_args end |
#init_block ⇒ Object (readonly)
Returns the value of attribute init_block.
15 16 17 |
# File 'lib/y_support/misc/inert_recorder.rb', line 15 def init_block @init_block end |
#recorded_messages ⇒ Object (readonly) Also known as: ρ
Returns the value of attribute recorded_messages.
15 16 17 |
# File 'lib/y_support/misc/inert_recorder.rb', line 15 def @recorded_messages end |
Instance Method Details
#blank? ⇒ Boolean
Always false.
34 |
# File 'lib/y_support/misc/inert_recorder.rb', line 34 def blank?; false end |
#present? ⇒ Boolean
Always true.
30 |
# File 'lib/y_support/misc/inert_recorder.rb', line 30 def present?; true end |
#respond_to?(ß, *args, &block) ⇒ Boolean
Always true.
38 |
# File 'lib/y_support/misc/inert_recorder.rb', line 38 def respond_to? ß, *args, █ true end |