Class: Featurevisor::Hooks::Hook
- Inherits:
-
Object
- Object
- Featurevisor::Hooks::Hook
- Defined in:
- lib/featurevisor/hooks.rb
Overview
Hook interface for extending evaluation behavior
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#call_after(evaluation, options) ⇒ Hash
Call the after hook if defined.
-
#call_before(options) ⇒ Hash
Call the before hook if defined.
-
#call_bucket_key(options) ⇒ String
Call the bucket key hook if defined.
-
#call_bucket_value(options) ⇒ Integer
Call the bucket value hook if defined.
-
#initialize(options) ⇒ Hook
constructor
Initialize a new hook.
Constructor Details
#initialize(options) ⇒ Hook
Initialize a new hook
17 18 19 20 21 22 23 |
# File 'lib/featurevisor/hooks.rb', line 17 def initialize() @name = [:name] @before = [:before] @bucket_key = [:bucket_key] @bucket_value = [:bucket_value] @after = [:after] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/featurevisor/hooks.rb', line 8 def name @name end |
Instance Method Details
#call_after(evaluation, options) ⇒ Hash
Call the after hook if defined
56 57 58 59 60 |
# File 'lib/featurevisor/hooks.rb', line 56 def call_after(evaluation, ) return evaluation unless @after @after.call(evaluation, ) end |
#call_before(options) ⇒ Hash
Call the before hook if defined
28 29 30 31 32 |
# File 'lib/featurevisor/hooks.rb', line 28 def call_before() return unless @before @before.call() end |
#call_bucket_key(options) ⇒ String
Call the bucket key hook if defined
37 38 39 40 41 |
# File 'lib/featurevisor/hooks.rb', line 37 def call_bucket_key() return [:bucket_key] unless @bucket_key @bucket_key.call() end |
#call_bucket_value(options) ⇒ Integer
Call the bucket value hook if defined
46 47 48 49 50 |
# File 'lib/featurevisor/hooks.rb', line 46 def call_bucket_value() return [:bucket_value] unless @bucket_value @bucket_value.call() end |