Class: ActiveModel::AttributeMethods::ClassMethods::AttributeMethodMatcher

### Home Classes Methods

### In Files

- lib/active_model/attribute_methods.rb

### Parent

Object

### Methods

- ::new
- #match
- #method_name
- #plain?

### Class/Module Index

Quicksearch

- ActiveModel
- ActiveModel::AttributeMethods
- ActiveModel::AttributeMethods::ClassMethods
- ActiveModel::AttributeMethods::ClassMethods::AttributeMethodMatcher
- ActiveModel::BlockValidator
- ActiveModel::Callbacks
- ActiveModel::Conversion
- ActiveModel::Dirty
- ActiveModel::EachValidator
- ActiveModel::Errors
- ActiveModel::Lint
- ActiveModel::Lint::Tests
- ActiveModel::MassAssignmentSecurity
- ActiveModel::MassAssignmentSecurity::BlackList
- ActiveModel::MassAssignmentSecurity::ClassMethods
- ActiveModel::MassAssignmentSecurity::Error
- ActiveModel::MassAssignmentSecurity::LoggerSanitizer
- ActiveModel::MassAssignmentSecurity::PermissionSet
- ActiveModel::MassAssignmentSecurity::Sanitizer
- ActiveModel::MassAssignmentSecurity::StrictSanitizer
- ActiveModel::MassAssignmentSecurity::WhiteList
- ActiveModel::MissingAttributeError
- ActiveModel::Name
- ActiveModel::Naming
- ActiveModel::Observer
- ActiveModel::ObserverArray
- ActiveModel::Observing
- ActiveModel::Observing::ClassMethods
- ActiveModel::SecurePassword
- ActiveModel::SecurePassword::ClassMethods
- ActiveModel::SecurePassword::InstanceMethodsOnActivation
- ActiveModel::Serialization
- ActiveModel::Serializers
- ActiveModel::Serializers::JSON
- ActiveModel::Serializers::Xml
- ActiveModel::StrictValidationFailed
- ActiveModel::Translation
- ActiveModel::Validations
- ActiveModel::Validations::AcceptanceValidator
- ActiveModel::Validations::Callbacks
- ActiveModel::Validations::Callbacks::ClassMethods
- ActiveModel::Validations::ClassMethods
- ActiveModel::Validations::ConfirmationValidator
- ActiveModel::Validations::ExclusionValidator
- ActiveModel::Validations::FormatValidator
- ActiveModel::Validations::HelperMethods
- ActiveModel::Validations::InclusionValidator
- ActiveModel::Validations::LengthValidator
- ActiveModel::Validations::NumericalityValidator
- ActiveModel::Validations::PresenceValidator
- ActiveModel::Validations::WithValidator
- ActiveModel::Validator

No matching classes.

# ActiveModel::AttributeMethods::ClassMethods::AttributeMethodMatcher

### Constants

AttributeMethodMatch

### Attributes

method_missing_target[R]
prefix[R]
suffix[R]

### Public Class Methods

new(options = {}) click to toggle source

    # File 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 = /\A(#{Regexp.escape(@prefix)})(.+?)(#{Regexp.escape(@suffix)})\z/
      @method_missing_target = "#{@prefix}attribute#{@suffix}"
      @method_name = "#{prefix}%s#{suffix}"
    end

### Public Instance Methods

match(method_name) click to toggle source

    # File 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) click to toggle source

    # File lib/active_model/attribute_methods.rb, line 381
    def method_name(attr_name)
      @method_name % attr_name
    end

plain?() click to toggle source

    # File lib/active_model/attribute_methods.rb, line 385
    def plain?
      prefix.empty? && suffix.empty?
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.