Class: Adornable::Machinery

Inherits:
Object
  • Object
show all
Defined in:
lib/adornable/machinery.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#accumulate_decorator!(name:, receiver:, defer_validation:) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/adornable/machinery.rb', line 12

def accumulate_decorator!(name:, receiver:, defer_validation:)
  name = name.to_sym
  receiver ||= find_suitable_receiver_for(name)
  validate_decorator!(name, receiver) unless defer_validation

  decorator = { name: name, receiver: receiver }
  accumulated_decorators << decorator
end

#accumulated_decorators?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/adornable/machinery.rb', line 21

def accumulated_decorators?
  Adornable::Utils.present?(accumulated_decorators)
end

#apply_accumulated_decorators_to_class_method!(method_name) ⇒ Object



30
31
32
33
# File 'lib/adornable/machinery.rb', line 30

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



25
26
27
28
# File 'lib/adornable/machinery.rb', line 25

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



8
9
10
# File 'lib/adornable/machinery.rb', line 8

def register_decorator_receiver!(receiver)
  registered_decorator_receivers.unshift(receiver)
end

#run_decorated_class_method(bound_method, *args) ⇒ Object



40
41
42
43
# File 'lib/adornable/machinery.rb', line 40

def run_decorated_class_method(bound_method, *args)
  decorators = get_class_method_decorators(bound_method.name)
  run_decorators(decorators, bound_method, *args)
end

#run_decorated_instance_method(bound_method, *args) ⇒ Object



35
36
37
38
# File 'lib/adornable/machinery.rb', line 35

def run_decorated_instance_method(bound_method, *args)
  decorators = get_instance_method_decorators(bound_method.name)
  run_decorators(decorators, bound_method, *args)
end