Module: Rubyzen::Providers::AttributesProvider

Included in:
Declarations::ClassDeclaration, Declarations::ModuleDeclaration
Defined in:
lib/rubyzen/providers/attributes_provider.rb

Overview

Provides access to attr_reader, attr_writer, and attr_accessor declarations.

Instance Method Summary collapse

Instance Method Details

#attributesRubyzen::Collections::AttributesCollection

Returns collection of attribute declarations.

Returns:



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/rubyzen/providers/attributes_provider.rb', line 6

def attributes
  attribute_nodes = node.each_descendant(:send).select do |send_node|
    %w[attr_reader attr_writer attr_accessor].include?(send_node.method_name.to_s)
  end

  attribute_declarations = attribute_nodes.map do |attr_node|
    Rubyzen::Declarations::AttributeDeclaration.new(attr_node, self)
  end

  Rubyzen::Collections::AttributesCollection.new(attribute_declarations)
end