Module: RailsBestPractices::Core::Check::Classable

Included in:
Prepares::ControllerPrepare, Prepares::MailerPrepare, Prepares::ModelPrepare
Defined in:
lib/rails_best_practices/core/check.rb

Overview

Helper to parse the class name.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/rails_best_practices/core/check.rb', line 174

def self.included(base)
  base.class_eval do
    interesting_nodes :module, :class

    # remember module name
    add_callback "start_module" do |node|
      classable_modules << node.module_name.to_s
    end

    # end of the module.
    add_callback "end_module" do |node|
      classable_modules.pop
    end

    # remember the class anem
    add_callback "start_class" do |node|
      @klass = Core::Klass.new(node.class_name.to_s, node.base_class.to_s, classable_modules)
    end

    # end of the class
    add_callback "end_class" do |node|
      @klass = nil
    end
  end
end

Instance Method Details

#classable_modulesObject

modules.



211
212
213
# File 'lib/rails_best_practices/core/check.rb', line 211

def classable_modules
  @class_moduels ||= []
end

#current_class_nameObject

get the current class name.



201
202
203
# File 'lib/rails_best_practices/core/check.rb', line 201

def current_class_name
  @klass.to_s
end

#current_extend_class_nameObject

get the current extend class name.



206
207
208
# File 'lib/rails_best_practices/core/check.rb', line 206

def current_extend_class_name
  @klass.extend_class_name
end