class RuboCop::Cop::Style::BisectedAttrAccessor::Macro
@api private
for use by ‘Style/BisectedAttrAccessor`.
Representation of an `attr_reader`, `attr_writer` or `attr` macro
def self.macro?(node)
def self.macro?(node) node.method?(:attr_reader) || node.method?(:attr_writer) || node.method?(:attr) end
def all_bisected?
def all_bisected? rest.none? end
def attr_names
def attr_names @attr_names ||= attrs.keys end
def bisect(*names)
def bisect(*names) @bisection = attrs.slice(*names).values end
def bisected_names
def bisected_names bisection.map(&:source) end
def initialize(node)
def initialize(node) @node = node @attrs = node.arguments.to_h { |attr| [attr.source, attr] } @bisection = [] end
def reader?
def reader? node.method?(:attr_reader) || node.method?(:attr) end
def rest
def rest @rest ||= attr_names - bisected_names end
def visibility
def visibility @visibility ||= node_visibility(node) end
def writer?
def writer? node.method?(:attr_writer) end