Module: RailsBestPractices::Core::Check::InheritedResourcesable

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

Overview

Helper to indicate if the controller is inherited from InheritedResources.

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
# File 'lib/rails_best_practices/core/check.rb', line 378

def self.included(base)
  base.class_eval do
    interesting_nodes :class, :var_ref, :vcall
    interesting_files CONTROLLER_FILES

    # check if the controller is inherit from InheritedResources::Base.
    add_callback "start_class" do |node|
      if "InheritedResources::Base" == current_extend_class_name
        @inherited_resources = true
      end
    end

    # check if there is a DSL call inherit_resources.
    add_callback "start_var_ref" do |node|
      if "inherit_resources" == node.to_s
        @inherited_resources = true
      end
    end

    # check if there is a DSL call inherit_resources.
    add_callback "start_vcall" do |node|
      if "inherit_resources" == node.to_s
        @inherited_resources = true
      end
    end
  end
end