Methods
M
N
P
Constants
AttributeMethodMatch = Struct.new(:target, :attr_name, :method_name)
 
Attributes
[R] method_missing_target
[R] prefix
[R] suffix
Class Public methods
new(options = {})
# File activemodel/lib/active_model/attribute_methods.rb, line 355
def initialize(options = {})
  options.symbolize_keys!

  if options[:prefix] == '' || options[:suffix] == ''
    ActiveSupport::Deprecation.warn(
      "Specifying an empty prefix/suffix for an attribute method is no longer "                  "necessary. If the un-prefixed/suffixed version of the method has not been "                  "defined when `define_attribute_methods` is called, it will be defined "                  "automatically."
    )
  end

  @prefix, @suffix = options[:prefix] || '', options[:suffix] || ''
  @regex = %r^(#{Regexp.escape(@prefix)})(.+?)(#{Regexp.escape(@suffix)})$/
  @method_missing_target = "#{@prefix}attribute#{@suffix}"
  @method_name = "#{prefix}%s#{suffix}"
end
Instance Public methods
match(method_name)
# File activemodel/lib/active_model/attribute_methods.rb, line 373
def match(method_name)
  if @regex =~ method_name
    AttributeMethodMatch.new(method_missing_target, $2, method_name)
  else
    nil
  end
end
method_name(attr_name)
# File activemodel/lib/active_model/attribute_methods.rb, line 381
def method_name(attr_name)
  @method_name % attr_name
end
plain?()
# File activemodel/lib/active_model/attribute_methods.rb, line 385
def plain?
  prefix.empty? && suffix.empty?
end