Class: Tagomatic::SystemConfiguration::MetaHandler
- Inherits:
-
Object
- Object
- Tagomatic::SystemConfiguration::MetaHandler
- Defined in:
- lib/tagomatic/system_configuration.rb
Instance Method Summary collapse
- #execute_invoke(method, arguments) ⇒ Object
- #extract_key ⇒ Object
-
#initialize(target, name) ⇒ MetaHandler
constructor
A new instance of MetaHandler.
- #invoke(arguments) ⇒ Object
- #is_calling?(method) ⇒ Boolean
Constructor Details
#initialize(target, name) ⇒ MetaHandler
Returns a new instance of MetaHandler.
32 33 34 35 |
# File 'lib/tagomatic/system_configuration.rb', line 32 def initialize(target, name) @target = target @name = name end |
Instance Method Details
#execute_invoke(method, arguments) ⇒ Object
51 52 53 54 55 |
# File 'lib/tagomatic/system_configuration.rb', line 51 def execute_invoke(method, arguments) key = extract_key full_arguments = [key] + arguments @target.send(method, *full_arguments) end |
#extract_key ⇒ Object
57 58 59 |
# File 'lib/tagomatic/system_configuration.rb', line 57 def extract_key @name.to_s.sub(/^[^_]+_/, '') end |
#invoke(arguments) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/tagomatic/system_configuration.rb', line 37 def invoke(arguments) if is_calling?(:register) execute_invoke :register, arguments elsif is_calling?(:retrieve) or is_calling?(:get) execute_invoke :retrieve, arguments else raise "unsupported invocation: #{@name}" end end |
#is_calling?(method) ⇒ Boolean
47 48 49 |
# File 'lib/tagomatic/system_configuration.rb', line 47 def is_calling?(method) @name.to_s.starts_with?("#{method}_") end |