Class: Macros::Base
- Inherits:
-
Object
- Object
- Macros::Base
- Includes:
- Uber::Callable
- Defined in:
- lib/macros/base.rb
Overview
Base class for all the Trbr step macros
Direct Known Subclasses
Auth, Auth::Authenticate, Auth::ExpireSessionData, Auth::SignIn, Auth::SignOut, Auth::SignOutAllScopes, Contract, Contract::ExtractParams, Contract::Prepopulate, Ctx, Ctx::Copy, Ctx::Inspect, Ctx::ValidatePresence, CurrentUser, CurrentUser::Set, Error, Error::SetFromContract, Model, Model::Build, Model::Copy, Model::Destroy, Model::Persist, Search, Search::Query, VerifyParams, VerifyParams::Date
Class Method Summary collapse
-
.register(step_name, proxy: false) ⇒ Object
To follow Trbr concept of named steps we have to register class instances with given class names - this method registers a class so it can be used with brackets.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Object
constructor
Single step object that can be used in operation step.
Constructor Details
#initialize(*args) ⇒ Object
Returns Single step object that can be used in operation step.
10 11 12 |
# File 'lib/macros/base.rb', line 10 def initialize(*args) self.args = args end |
Class Method Details
.register(step_name, proxy: false) ⇒ Object
To follow Trbr concept of named steps we have to register class instances with given class names - this method registers a class so it can be used with brackets. It will create a method that has a name that has the same name as a class from which we want to use an object to handle a step
24 25 26 27 28 29 30 31 |
# File 'lib/macros/base.rb', line 24 def self.register(step_name, proxy: false) klass = step_name.to_s.split('_').collect(&:capitalize).join define_singleton_method klass do |*args| base = "#{self}::#{klass}".constantize proxy ? base.new(*args).call : base.new(*args) end end |