Method: Injectable::ClassMethods#argument
- Defined in:
- lib/injectable/class_methods.rb
#argument(name, options = {}) ⇒ Object
Declare the arguments for ‘#call` and initialize the accessors This helps us clean up the code for memoization:
“‘ private
def player
# player_id exists in the context because we added it as an argument
@player ||= player_query.call(player_id)
end “‘
Every argument is required unless given an optional default value
133 134 135 136 |
# File 'lib/injectable/class_methods.rb', line 133 def argument(name, = {}) call_arguments[name] = attr_accessor name end |