Class: ActiveModel::AttributeMethods::ClassMethods::AttributeMethodMatcher
- Inherits:
-
Object
- Object
- ActiveModel::AttributeMethods::ClassMethods::AttributeMethodMatcher
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/lib/active_model/attribute_methods.rb
Overview
:nodoc:
Defined Under Namespace
Classes: AttributeMethodMatch
Instance Attribute Summary collapse
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#suffix ⇒ Object
readonly
Returns the value of attribute suffix.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
-
#initialize(prefix: "", suffix: "", parameters: nil) ⇒ AttributeMethodMatcher
constructor
A new instance of AttributeMethodMatcher.
- #match(method_name) ⇒ Object
- #method_name(attr_name) ⇒ Object
Constructor Details
#initialize(prefix: "", suffix: "", parameters: nil) ⇒ AttributeMethodMatcher
Returns a new instance of AttributeMethodMatcher.
422 423 424 425 426 427 428 429 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/lib/active_model/attribute_methods.rb', line 422 def initialize(prefix: "", suffix: "", parameters: nil) @prefix = prefix @suffix = suffix @parameters = parameters.nil? ? FORWARD_PARAMETERS : parameters @regex = /^(?:#{Regexp.escape(@prefix)})(.*)(?:#{Regexp.escape(@suffix)})$/ @target = "#{@prefix}attribute#{@suffix}" @method_name = "#{prefix}%s#{suffix}" end |
Instance Attribute Details
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
418 419 420 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/lib/active_model/attribute_methods.rb', line 418 def parameters @parameters end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
418 419 420 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/lib/active_model/attribute_methods.rb', line 418 def prefix @prefix end |
#suffix ⇒ Object (readonly)
Returns the value of attribute suffix.
418 419 420 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/lib/active_model/attribute_methods.rb', line 418 def suffix @suffix end |
Instance Method Details
#match(method_name) ⇒ Object
431 432 433 434 435 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/lib/active_model/attribute_methods.rb', line 431 def match(method_name) if @regex =~ method_name AttributeMethodMatch.new(target, $1) end end |
#method_name(attr_name) ⇒ Object
437 438 439 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/lib/active_model/attribute_methods.rb', line 437 def method_name(attr_name) @method_name % attr_name end |