Class: ActiveModel::AttributeMethods::ClassMethods::AttributeMethodPattern
- Inherits:
 - 
      Object
      
        
- Object
 - ActiveModel::AttributeMethods::ClassMethods::AttributeMethodPattern
 
 
- Defined in:
 - lib/active_model/attribute_methods.rb
 
Overview
:nodoc:
Defined Under Namespace
Classes: AttributeMethod
Instance Attribute Summary collapse
- 
  
    
      #parameters  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute parameters.
 - 
  
    
      #prefix  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute prefix.
 - 
  
    
      #proxy_target  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute proxy_target.
 - 
  
    
      #suffix  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute suffix.
 
Instance Method Summary collapse
- 
  
    
      #initialize(prefix: "", suffix: "", parameters: nil)  ⇒ AttributeMethodPattern 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of AttributeMethodPattern.
 - #match(method_name) ⇒ Object
 - #method_name(attr_name) ⇒ Object
 
Constructor Details
#initialize(prefix: "", suffix: "", parameters: nil) ⇒ AttributeMethodPattern
Returns a new instance of AttributeMethodPattern.
      453 454 455 456 457 458 459 460  | 
    
      # File 'lib/active_model/attribute_methods.rb', line 453 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/ @proxy_target = "#{@prefix}attribute#{@suffix}" @method_name = "#{prefix}%s#{suffix}" end  | 
  
Instance Attribute Details
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
      449 450 451  | 
    
      # File 'lib/active_model/attribute_methods.rb', line 449 def parameters @parameters end  | 
  
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
      449 450 451  | 
    
      # File 'lib/active_model/attribute_methods.rb', line 449 def prefix @prefix end  | 
  
#proxy_target ⇒ Object (readonly)
Returns the value of attribute proxy_target.
      449 450 451  | 
    
      # File 'lib/active_model/attribute_methods.rb', line 449 def proxy_target @proxy_target end  | 
  
#suffix ⇒ Object (readonly)
Returns the value of attribute suffix.
      449 450 451  | 
    
      # File 'lib/active_model/attribute_methods.rb', line 449 def suffix @suffix end  | 
  
Instance Method Details
#match(method_name) ⇒ Object
      462 463 464 465 466  | 
    
      # File 'lib/active_model/attribute_methods.rb', line 462 def match(method_name) if @regex =~ method_name AttributeMethod.new(proxy_target, $1) end end  | 
  
#method_name(attr_name) ⇒ Object
      468 469 470  | 
    
      # File 'lib/active_model/attribute_methods.rb', line 468 def method_name(attr_name) @method_name % attr_name end  |