Class: Adornable::Machinery
- Inherits:
-
Object
- Object
- Adornable::Machinery
- Defined in:
- lib/adornable/machinery.rb
Overview
:nodoc:
Instance Method Summary collapse
- #accumulate_decorator!(name:, receiver:, defer_validation:, decorator_options:) ⇒ Object
- #accumulated_decorators? ⇒ Boolean
- #apply_accumulated_decorators_to_class_method!(method_name) ⇒ Object
- #apply_accumulated_decorators_to_instance_method!(method_name) ⇒ Object
- #register_decorator_receiver!(receiver) ⇒ Object
- #run_decorated_class_method(bound_method, *args, **kwargs) ⇒ Object
- #run_decorated_instance_method(bound_method, *args, **kwargs) ⇒ Object
Instance Method Details
#accumulate_decorator!(name:, receiver:, defer_validation:, decorator_options:) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/adornable/machinery.rb', line 13 def accumulate_decorator!(name:, receiver:, defer_validation:, decorator_options:) name = name.to_sym receiver ||= find_suitable_receiver_for(name) validate_decorator!(name, receiver) unless defer_validation decorator = { name: name, receiver: receiver, options: || {}, } accumulated_decorators << decorator end |
#accumulated_decorators? ⇒ Boolean
27 28 29 |
# File 'lib/adornable/machinery.rb', line 27 def accumulated_decorators? Adornable::Utils.present?(accumulated_decorators) end |
#apply_accumulated_decorators_to_class_method!(method_name) ⇒ Object
36 37 38 39 |
# File 'lib/adornable/machinery.rb', line 36 def apply_accumulated_decorators_to_class_method!(method_name) set_class_method_decorators!(method_name, accumulated_decorators) clear_accumulated_decorators! end |
#apply_accumulated_decorators_to_instance_method!(method_name) ⇒ Object
31 32 33 34 |
# File 'lib/adornable/machinery.rb', line 31 def apply_accumulated_decorators_to_instance_method!(method_name) set_instance_method_decorators!(method_name, accumulated_decorators) clear_accumulated_decorators! end |
#register_decorator_receiver!(receiver) ⇒ Object
9 10 11 |
# File 'lib/adornable/machinery.rb', line 9 def register_decorator_receiver!(receiver) registered_decorator_receivers.unshift(receiver) end |
#run_decorated_class_method(bound_method, *args, **kwargs) ⇒ Object
46 47 48 49 |
# File 'lib/adornable/machinery.rb', line 46 def run_decorated_class_method(bound_method, *args, **kwargs) decorators = get_class_method_decorators(bound_method.name) run_decorators(decorators, bound_method, *args, **kwargs) end |
#run_decorated_instance_method(bound_method, *args, **kwargs) ⇒ Object
41 42 43 44 |
# File 'lib/adornable/machinery.rb', line 41 def run_decorated_instance_method(bound_method, *args, **kwargs) decorators = get_instance_method_decorators(bound_method.name) run_decorators(decorators, bound_method, *args, **kwargs) end |