Class: ActiveAccess::AttributeConventions

Inherits:
Object
  • Object
show all
Defined in:
lib/active_access/attribute_conventions.rb

Constant Summary collapse

MethodMatcher =
ActiveModel::AttributeMethods::ClassMethods::
AttributeMethodMatcher
READ_MATCHERS =
[
  MethodMatcher.new, # "plain" reader
  MethodMatcher.new(suffix: '_changed?'),
  MethodMatcher.new(suffix: '_change'),
  MethodMatcher.new(suffix: '_was'),
  MethodMatcher.new(suffix: '_before_type_cast'),
  MethodMatcher.new(prefix: '_'),
  MethodMatcher.new(prefix: '?')
]
WRITE_MATCHERS =
[
  MethodMatcher.new(prefix: 'reset_', suffix: '!'),
  MethodMatcher.new(suffix: '_will_change'),
  MethodMatcher.new(suffix: '=')
]

Class Method Summary collapse

Class Method Details

.reader_names(attr) ⇒ Object



28
29
30
# File 'lib/active_access/attribute_conventions.rb', line 28

def reader_names(attr)
  READ_MATCHERS.map { |matcher| matcher.method_name(attr) }
end

.writer_names(attr) ⇒ Object



32
33
34
# File 'lib/active_access/attribute_conventions.rb', line 32

def writer_names(attr)
  WRITE_MATCHERS.map { |matcher| matcher.method_name(attr) }
end