Class: LintFu::Plugins::ActiveRecord::ModelEidosBuilder
- Inherits:
-
EidosBuilder
- Object
- SexpProcessor
- EidosBuilder
- LintFu::Plugins::ActiveRecord::ModelEidosBuilder
- Defined in:
- lib/lint_fu/plugins/active_record/model_eidos_builder.rb
Constant Summary collapse
- SIGNATURE_SEXP =
s(:colon2, s(:const, :ActiveRecord), :Base)
- SINGULAR_ASSOCS =
Set.new([:belongs_to, :has_one])
- PLURAL_ASSOCS =
Set.new([:has_many, :has_and_belongs_to_many])
- ASSOCS =
SINGULAR_ASSOCS + PLURAL_ASSOCS
Instance Attribute Summary
Attributes inherited from EidosBuilder
#current_model_element, #eide, #namespace
Instance Method Summary collapse
-
#process_call(sexp) ⇒ Object
s(:call, nil, :belongs_to, s(:arglist, s(:lit, :relation_name))).
-
#process_class(sexp) ⇒ Object
- sexp
-
[:class, <classname>, <superclass|nil>, <CLASS DEFS>].
Methods inherited from EidosBuilder
#build, #initialize, #process_module
Constructor Details
This class inherits a constructor from LintFu::EidosBuilder
Instance Method Details
#process_call(sexp) ⇒ Object
s(:call, nil, :belongs_to, s(:arglist, s(:lit, :relation_name)))
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/lint_fu/plugins/active_record/model_eidos_builder.rb', line 32 def process_call(sexp) return sexp unless self.current_model_element callee, method, arglist = sexp[1], sexp[2], sexp[3] arglist = nil unless arglist[0] == :arglist discover_associations(callee, method, arglist) discover_named_scopes(callee, method, arglist) discover_paranoia(callee, method, arglist) return sexp end |
#process_class(sexp) ⇒ Object
- sexp
- :class, <classname>, <superclass|nil>, <CLASS DEFS>
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/lint_fu/plugins/active_record/model_eidos_builder.rb', line 11 def process_class(sexp) #always assume everything we see is a model #cheap way to deal with model class hierarchy! #return super(sexp) unless sexp[2] && sexp[2] == SIGNATURE_SEXP unless self.current_model_element self.current_model_element = ModelEidos.new(sexp, self.namespace) did_element = true end ret = super(sexp) if did_element self.eide.push self.current_model_element self.current_model_element = nil end return ret end |