Class: ActiveModel::AttributeMethods::ClassMethods::AttributeMethodPatternSet
Do not use. This class is for internal use only.
| Relationships & Source Files | |
| Inherits: | Object |
| Defined in: | activemodel/lib/active_model/attribute_methods.rb |
Class Method Summary
- .new(patterns) ⇒ AttributeMethodPatternSet constructor
Instance Attribute Summary
- #patterns readonly protected
Instance Method Summary
Constructor Details
.new(patterns) ⇒ AttributeMethodPatternSet
# File 'activemodel/lib/active_model/attribute_methods.rb', line 499
def initialize(patterns) @patterns = patterns.freeze @affixed = patterns.reject { |pattern| pattern.prefix.empty? && pattern.suffix.empty? }.freeze @prefixes = @affixed.map(&:prefix).reject(&:empty?).uniq.freeze @suffixes = @affixed.map(&:suffix).reject(&:empty?).uniq.freeze freeze end
Instance Attribute Details
#patterns (readonly, protected)
[ GitHub ]# File 'activemodel/lib/active_model/attribute_methods.rb', line 527
attr_reader :patterns
Instance Method Details
#+(other)
[ GitHub ]# File 'activemodel/lib/active_model/attribute_methods.rb', line 513
def +(other) AttributeMethodPatternSet.new(@patterns + other) end
#==(other)
[ GitHub ]#each(&block)
[ GitHub ]# File 'activemodel/lib/active_model/attribute_methods.rb', line 509
def each(&block) @patterns.each(&block) end
#matching(method_name)
[ GitHub ]# File 'activemodel/lib/active_model/attribute_methods.rb', line 521
def matching(method_name) return if @affixed.empty? @affixed if method_name.end_with?(*@suffixes) || method_name.start_with?(*@prefixes) end