Class: Configatron::Proc
- Inherits:
-
Object
- Object
- Configatron::Proc
- Defined in:
- lib/configatron/proc.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#execution_count ⇒ Object
Returns the value of attribute execution_count.
Instance Method Summary collapse
- #call ⇒ Object
- #finalize? ⇒ Boolean
-
#initialize(&block) ⇒ Proc
constructor
A new instance of Proc.
- #inspect ⇒ Object
Constructor Details
#initialize(&block) ⇒ Proc
Returns a new instance of Proc.
8 9 10 11 |
# File 'lib/configatron/proc.rb', line 8 def initialize(&block) self.execution_count = 0 self.block = block end |
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
6 7 8 |
# File 'lib/configatron/proc.rb', line 6 def block @block end |
#execution_count ⇒ Object
Returns the value of attribute execution_count.
5 6 7 |
# File 'lib/configatron/proc.rb', line 5 def execution_count @execution_count end |
Instance Method Details
#call ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/configatron/proc.rb', line 13 def call unless @val val = self.block.call self.execution_count += 1 if finalize? @val = val end end return val || @val end |
#finalize? ⇒ Boolean
24 25 26 |
# File 'lib/configatron/proc.rb', line 24 def finalize? true end |
#inspect ⇒ Object
28 29 30 |
# File 'lib/configatron/proc.rb', line 28 def inspect call.inspect end |