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( validate validates validates! validates_each validates_with 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.
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/simplabs/excellent/parsing/class_context.rb', line 39 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.
36 37 38 |
# File 'lib/simplabs/excellent/parsing/class_context.rb', line 36 def base_class_name @base_class_name end |
#line_count ⇒ Object (readonly)
Returns the value of attribute line_count.
35 36 37 |
# File 'lib/simplabs/excellent/parsing/class_context.rb', line 35 def line_count @line_count end |
#methods ⇒ Object (readonly)
Returns the value of attribute methods.
34 35 36 |
# File 'lib/simplabs/excellent/parsing/class_context.rb', line 34 def methods @methods end |
#validations ⇒ Object (readonly)
Returns the value of attribute validations.
37 38 39 |
# File 'lib/simplabs/excellent/parsing/class_context.rb', line 37 def validations @validations end |
Instance Method Details
#active_record_model? ⇒ Boolean
51 52 53 |
# File 'lib/simplabs/excellent/parsing/class_context.rb', line 51 def active_record_model? @base_class_name == 'ActiveRecord::Base' end |
#defines_initializer? ⇒ Boolean
63 64 65 |
# File 'lib/simplabs/excellent/parsing/class_context.rb', line 63 def defines_initializer? @initializer end |
#process_call(exp) ⇒ Object
71 72 73 74 75 |
# File 'lib/simplabs/excellent/parsing/class_context.rb', line 71 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
77 78 79 80 |
# File 'lib/simplabs/excellent/parsing/class_context.rb', line 77 def process_defn(exp) @initializer = exp[1] == :initialize super end |
#specifies_attr_accessible? ⇒ Boolean
55 56 57 |
# File 'lib/simplabs/excellent/parsing/class_context.rb', line 55 def specifies_attr_accessible? @attr_accessible end |
#specifies_attr_protected? ⇒ Boolean
59 60 61 |
# File 'lib/simplabs/excellent/parsing/class_context.rb', line 59 def specifies_attr_protected? @attr_protected end |
#validating? ⇒ Boolean
67 68 69 |
# File 'lib/simplabs/excellent/parsing/class_context.rb', line 67 def validating? !@validations.empty? || @methods.any?{ |method| %(validate validate_on_create validate_on_update).include?(method.name) } end |