Module: LintFu::ModelElement

Included in:
ActionPack::ModelController, ActiveRecord::ModelModel, Rails::ModelApplication
Defined in:
lib/lint_fu/model_element.rb

Overview

An element of the static analysis model being created; generally corresponds to a class (e.g. model, controller or view) within the application being scanned.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#modeled_class_nameObject (readonly)

Returns the value of attribute modeled_class_name.



30
31
32
# File 'lib/lint_fu/model_element.rb', line 30

def modeled_class_name
  @modeled_class_name
end

#modeled_class_superclass_nameObject (readonly)

Returns the value of attribute modeled_class_superclass_name.



30
31
32
# File 'lib/lint_fu/model_element.rb', line 30

def modeled_class_superclass_name
  @modeled_class_superclass_name
end

#parse_treeObject (readonly)

Returns the value of attribute parse_tree.



30
31
32
# File 'lib/lint_fu/model_element.rb', line 30

def parse_tree
  @parse_tree
end

#supermodelObject

Returns the value of attribute supermodel.



29
30
31
# File 'lib/lint_fu/model_element.rb', line 29

def supermodel
  @supermodel
end

Instance Method Details

#initialize(sexp, namespace = nil) ⇒ Object

sexp
:class, <classname>, <superclass|nil>, <CLASS DEFS>
namespace

Array of enclosing module names for this class



34
35
36
37
38
39
40
41
# File 'lib/lint_fu/model_element.rb', line 34

def initialize(sexp, namespace=nil)
  @parse_tree = sexp
  if namespace
    @modeled_class_name = namespace.join('::') + (namespace.empty? ? '' : '::') + sexp[1].to_s
  else
    @modeled_class_name = sexp[1]
  end
end

#to_sObject

Have a pretty string representation



44
45
46
# File 'lib/lint_fu/model_element.rb', line 44

def to_s
  "<<model of #{modeled_class_name}>>"
end