Class: Core::Endpoint::BasicHandler::Actions::Guards::Guard
- Inherits:
-
Object
- Object
- Core::Endpoint::BasicHandler::Actions::Guards::Guard
- Defined in:
- app/api/core/endpoint/basic_handler/actions/guards.rb
Instance Method Summary collapse
-
#initialize(method = nil, &block) ⇒ Guard
constructor
rubocop:todo Metrics/MethodLength.
Constructor Details
#initialize(method = nil, &block) ⇒ Guard
rubocop:todo Metrics/MethodLength
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/api/core/endpoint/basic_handler/actions/guards.rb', line 4 def initialize(method = nil, &block) # rubocop:todo Metrics/MethodLength if method.present? line = __LINE__ + 1 singleton_class.class_eval( " def execute(object) object.#{method} end ", __FILE__, line ) elsif block singleton_class.send(:define_method, :execute, &block) else raise StandardError, 'Either method name or block is required for guards' end end |