class ActiveModel::AttributeMethods::ClassMethods::AttributeMethodMatcher

Constants

AttributeMethodMatch

Attributes

prefix[R]
suffix[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/active_model/attribute_methods.rb, line 347
def initialize(options = {})
  options.symbolize_keys!
  @prefix, @suffix = options[:prefix] || '', options[:suffix] || ''
  @regex = %r^(#{Regexp.escape(@prefix)})(.+?)(#{Regexp.escape(@suffix)})$/
end

Public Instance Methods

match(method_name) click to toggle source
# File lib/active_model/attribute_methods.rb, line 353
def match(method_name)
  if matchdata = @regex.match(method_name)
    AttributeMethodMatch.new(method_missing_target, matchdata[2])
  else
    nil
  end
end
method_missing_target() click to toggle source
# File lib/active_model/attribute_methods.rb, line 365
def method_missing_target
  :"#{prefix}attribute#{suffix}"
end
method_name(attr_name) click to toggle source
# File lib/active_model/attribute_methods.rb, line 361
def method_name(attr_name)
  "#{prefix}#{attr_name}#{suffix}"
end