Class: Simplabs::Excellent::Parsing::ClassContext
- Inherits:
-
SexpContext
- Object
- SexpContext
- Simplabs::Excellent::Parsing::ClassContext
- Includes:
- FlogMeasure, Scopeable
- Defined in:
- lib/simplabs/excellent/parsing/class_context.rb
Overview
:nodoc:
Constant Summary collapse
- VALIDATIONS =
%w( validates_acceptance_of validates_associated validates_confirmation_of validates_each validates_exclusion_of validates_format_of validates_inclusion_of validates_length_of validates_numericality_of validates_presence_of validates_size_of validates_uniqueness_of )
Constants included from FlogMeasure
FlogMeasure::BRANCHES, FlogMeasure::SCORES
Instance Attribute Summary collapse
-
#base_class_name ⇒ Object
readonly
Returns the value of attribute base_class_name.
-
#line_count ⇒ Object
readonly
Returns the value of attribute line_count.
-
#methods ⇒ Object
readonly
Returns the value of attribute methods.
-
#validations ⇒ Object
readonly
Returns the value of attribute validations.
Attributes inherited from SexpContext
Instance Method Summary collapse
- #active_record_model? ⇒ Boolean
- #defines_initializer? ⇒ Boolean
-
#initialize(exp, parent) ⇒ ClassContext
constructor
A new instance of ClassContext.
- #process_call(exp) ⇒ Object
- #process_defn(exp) ⇒ Object
- #specifies_attr_accessible? ⇒ Boolean
- #specifies_attr_protected? ⇒ Boolean
- #validating? ⇒ Boolean
Methods included from FlogMeasure
#flog_score, #process_alias, #process_and, #process_attrasgn, #process_attrset, #process_block_pass, #process_case, #process_dasgn_curr, #process_else, #process_iasgn, #process_if, #process_iter, #process_lasgn, #process_lit, #process_masgn, #process_or, #process_rescue, #process_sclass, #process_super, #process_until, #process_when, #process_while, #process_yield
Methods inherited from SexpContext
Constructor Details
#initialize(exp, parent) ⇒ ClassContext
Returns a new instance of ClassContext.
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/simplabs/excellent/parsing/class_context.rb', line 34 def initialize(exp, parent) super @name, @full_name = get_names @base_class_name = get_base_class_name @methods = [] @line_count = count_lines @attr_accessible = false @attr_protected = false @initializer = false @validations = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Simplabs::Excellent::Parsing::SexpContext
Instance Attribute Details
#base_class_name ⇒ Object (readonly)
Returns the value of attribute base_class_name.
31 32 33 |
# File 'lib/simplabs/excellent/parsing/class_context.rb', line 31 def base_class_name @base_class_name end |
#line_count ⇒ Object (readonly)
Returns the value of attribute line_count.
30 31 32 |
# File 'lib/simplabs/excellent/parsing/class_context.rb', line 30 def line_count @line_count end |
#methods ⇒ Object (readonly)
Returns the value of attribute methods.
29 30 31 |
# File 'lib/simplabs/excellent/parsing/class_context.rb', line 29 def methods @methods end |
#validations ⇒ Object (readonly)
Returns the value of attribute validations.
32 33 34 |
# File 'lib/simplabs/excellent/parsing/class_context.rb', line 32 def validations @validations end |
Instance Method Details
#active_record_model? ⇒ Boolean
46 47 48 |
# File 'lib/simplabs/excellent/parsing/class_context.rb', line 46 def active_record_model? @base_class_name == 'ActiveRecord::Base' end |
#defines_initializer? ⇒ Boolean
58 59 60 |
# File 'lib/simplabs/excellent/parsing/class_context.rb', line 58 def defines_initializer? @initializer end |
#process_call(exp) ⇒ Object
66 67 68 69 70 |
# File 'lib/simplabs/excellent/parsing/class_context.rb', line 66 def process_call(exp) @attr_accessible = true if exp[2] == :attr_accessible @attr_protected = true if exp[2] == :attr_protected super end |
#process_defn(exp) ⇒ Object
72 73 74 75 |
# File 'lib/simplabs/excellent/parsing/class_context.rb', line 72 def process_defn(exp) @initializer = true if exp[2] == :initialize super end |
#specifies_attr_accessible? ⇒ Boolean
50 51 52 |
# File 'lib/simplabs/excellent/parsing/class_context.rb', line 50 def specifies_attr_accessible? @attr_accessible end |
#specifies_attr_protected? ⇒ Boolean
54 55 56 |
# File 'lib/simplabs/excellent/parsing/class_context.rb', line 54 def specifies_attr_protected? @attr_protected end |
#validating? ⇒ Boolean
62 63 64 |
# File 'lib/simplabs/excellent/parsing/class_context.rb', line 62 def validating? !@validations.empty? || @methods.any?{ |method| %(validate validate_on_create validate_on_update).include?(method.name) } end |