class ActiveModel::AttributeMethods::ClassMethods::AttributeMethodMatcher
:nodoc:
def initialize(prefix: "", suffix: "", parameters: nil)
def initialize(prefix: "", suffix: "", parameters: nil) @prefix = prefix @suffix = suffix @parameters = parameters.nil? ? FORWARD_PARAMETERS : parameters @regex = /\A(?:#{Regexp.escape(@prefix)})(.*)(?:#{Regexp.escape(@suffix)})\z/ @target = "#{@prefix}attribute#{@suffix}" @method_name = "#{prefix}%s#{suffix}" end
def match(method_name)
def match(method_name) if @regex =~ method_name AttributeMethodMatch.new(target, $1) end end
def method_name(attr_name)
def method_name(attr_name) @method_name % attr_name end