Class: SnipSnip::Registry
- Inherits:
-
Object
- Object
- SnipSnip::Registry
- Defined in:
- lib/snip_snip/registry.rb
Overview
A list of records that were found during the course of the last request on which we are tracking columns.
Instance Attribute Summary collapse
-
#records ⇒ Object
readonly
Returns the value of attribute records.
Class Method Summary collapse
-
.instance ⇒ Object
The singleton instance of this registry.
-
.method_missing(method, *args, &block) ⇒ Object
Delegate all missing methods to the singleton instance.
-
.respond_to_missing?(method, include_private = false) ⇒ Boolean
Respond to all of the missing methods on the singleton instance.
Instance Method Summary collapse
-
#clear ⇒ Object
Wipe the registry clear of found objects so that we don’t report on them twice.
-
#each_record(&block) ⇒ Object
Loop through each record that was found during the lifespan of this registry.
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
-
#register(record) ⇒ Object
Add a record to this registry.
Constructor Details
#initialize ⇒ Registry
Returns a new instance of Registry.
9 10 11 |
# File 'lib/snip_snip/registry.rb', line 9 def initialize clear end |
Instance Attribute Details
#records ⇒ Object (readonly)
Returns the value of attribute records.
7 8 9 |
# File 'lib/snip_snip/registry.rb', line 7 def records @records end |
Class Method Details
.instance ⇒ Object
The singleton instance of this registry.
34 35 36 |
# File 'lib/snip_snip/registry.rb', line 34 def instance @instance ||= new end |
.method_missing(method, *args, &block) ⇒ Object
Delegate all missing methods to the singleton instance.
39 40 41 42 43 |
# File 'lib/snip_snip/registry.rb', line 39 def method_missing(method, *args, &block) return super unless respond_to_missing?(method) instance.public_send(method, *args, &block) end |
.respond_to_missing?(method, include_private = false) ⇒ Boolean
Respond to all of the missing methods on the singleton instance.
46 47 48 |
# File 'lib/snip_snip/registry.rb', line 46 def respond_to_missing?(method, include_private = false) instance.respond_to?(method) || super end |
Instance Method Details
#clear ⇒ Object
Wipe the registry clear of found objects so that we don’t report on them twice.
15 16 17 |
# File 'lib/snip_snip/registry.rb', line 15 def clear @records = [] end |
#each_record(&block) ⇒ Object
Loop through each record that was found during the lifespan of this registry
21 22 23 24 25 |
# File 'lib/snip_snip/registry.rb', line 21 def each_record(&block) return to_enum(:each_record) unless block_given? records.each(&block) end |
#register(record) ⇒ Object
Add a record to this registry
28 29 30 |
# File 'lib/snip_snip/registry.rb', line 28 def register(record) records << record end |