Module: Aquarium::Aspects::AdviceChainNodeFactory

Defined in:
lib/aquarium/aspects/advice.rb

Overview

The advice_kind argument must be one of the values returned by Advice.kinds or one of the special values “:no” or “:none”, signfying a node for which there is no advice, where the actual method being advised is called directly instead. This kind of node is normally used as the terminal leaf in the chain.

Class Method Summary collapse

Class Method Details

.make_node(options = {}) ⇒ Object



276
277
278
279
280
281
282
283
# File 'lib/aquarium/aspects/advice.rb', line 276

def self.make_node options = {}
  advice_kind = options[:advice_kind]
  raise Aquarium::Utils::InvalidOptions.new("Unknown advice kind specified: #{advice_kind}") unless valid(advice_kind)
  advice_kind = :no if advice_kind == :none
  advice_chain_node_name = advice_kind.to_s.to_camel_case + "AdviceChainNode"
  clazz = Aquarium::Aspects.const_get advice_chain_node_name
  clazz.new options
end

.valid(advice_kind) ⇒ Object



285
286
287
# File 'lib/aquarium/aspects/advice.rb', line 285

def self.valid advice_kind
  advice_kind == :no || advice_kind == :none || Advice.kinds.include?(advice_kind)
end