Sha256: e89dcee67d8b3da57934313bcb41bf8e6a6465b0dbddb6e84c92903bb77af424
Contents?: true
Size: 1.1 KB
Versions: 1
Compression:
Stored size: 1.1 KB
Contents
# frozen_string_literal: true module Kanal module Core module Helpers # Module assumes that class where it was included has methods # set(name, value) # get(name) # transforms unknown methods to setters/getters for parameters module ParameterFinderWithMethodMissingMixin def method_missing(symbol, *args) parameter_name = symbol.to_s parameter_name.sub! "=", "" parameter_name = parameter_name.to_sym # standard workflow with settings properties with # input.prop = 123 if symbol.to_s.include? "=" @parameter_bag.set parameter_name, args.first else # this approach can be used also in dsl # like that # setters: prop value # getters: prop if !args.empty? # means it is used as setter in dsl, # method call with argument @parameter_bag.set(parameter_name, *args) else @parameter_bag.get parameter_name end end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kanal-0.3.0 | lib/kanal/core/helpers/parameter_finder_with_method_missing_mixin.rb |