Class: PageEz::Visitors::MacroPluralizationVisitor
- Inherits:
-
Object
- Object
- PageEz::Visitors::MacroPluralizationVisitor
- Defined in:
- lib/page_ez/visitors/macro_pluralization_visitor.rb
Instance Method Summary collapse
- #begin_block_evaluation ⇒ Object
- #define_method(name) ⇒ Object
- #end_block_evaluation ⇒ Object
- #inherit_from(subclass) ⇒ Object
-
#initialize ⇒ MacroPluralizationVisitor
constructor
A new instance of MacroPluralizationVisitor.
- #process_macro(macro, name, construction_strategy) ⇒ Object
- #reset ⇒ Object
- #track_method_added(name, construction_strategy) ⇒ Object
- #track_method_delegated(name) ⇒ Object
- #track_method_renamed(from, to) ⇒ Object
- #track_method_undefined(name) ⇒ Object
Constructor Details
#initialize ⇒ MacroPluralizationVisitor
Returns a new instance of MacroPluralizationVisitor.
4 5 6 |
# File 'lib/page_ez/visitors/macro_pluralization_visitor.rb', line 4 def initialize reset end |
Instance Method Details
#begin_block_evaluation ⇒ Object
8 9 10 |
# File 'lib/page_ez/visitors/macro_pluralization_visitor.rb', line 8 def begin_block_evaluation @depth_visitor.begin_block_evaluation end |
#define_method(name) ⇒ Object
16 17 18 |
# File 'lib/page_ez/visitors/macro_pluralization_visitor.rb', line 16 def define_method(name) @depth_visitor.define_method(name) end |
#end_block_evaluation ⇒ Object
12 13 14 |
# File 'lib/page_ez/visitors/macro_pluralization_visitor.rb', line 12 def end_block_evaluation @depth_visitor.end_block_evaluation end |
#inherit_from(subclass) ⇒ Object
20 21 22 |
# File 'lib/page_ez/visitors/macro_pluralization_visitor.rb', line 20 def inherit_from(subclass) @depth_visitor.inherit_from(subclass) end |
#process_macro(macro, name, construction_strategy) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/page_ez/visitors/macro_pluralization_visitor.rb', line 40 def process_macro(macro, name, construction_strategy) @depth_visitor.process_macro(macro, name, construction_strategy) rendered = "#{macro} :#{name}, \"#{construction_strategy.selector}\"" = case [macro, Pluralization.new(name).singular? ? :singular : :plural] in [:has_one, :plural] "consider singularizing :#{name} in #{rendered}" in [:has_many, :singular] "consider pluralizing :#{name} in #{rendered}" in [:has_many_ordered, :singular] "consider pluralizing :#{name} in #{rendered}" in _ end if = "#{" " * @depth_visitor.depth}#{}" case PageEz.configuration.on_pluralization_mismatch when :warn PageEz.configuration.logger.warn() when :raise raise PluralizationMismatchError, end end end |
#reset ⇒ Object
65 66 67 |
# File 'lib/page_ez/visitors/macro_pluralization_visitor.rb', line 65 def reset @depth_visitor = DepthVisitor.new end |
#track_method_added(name, construction_strategy) ⇒ Object
24 25 26 |
# File 'lib/page_ez/visitors/macro_pluralization_visitor.rb', line 24 def track_method_added(name, construction_strategy) @depth_visitor.track_method_added(name, construction_strategy) end |
#track_method_delegated(name) ⇒ Object
36 37 38 |
# File 'lib/page_ez/visitors/macro_pluralization_visitor.rb', line 36 def track_method_delegated(name) @depth_visitor.track_method_delegated(name) end |
#track_method_renamed(from, to) ⇒ Object
32 33 34 |
# File 'lib/page_ez/visitors/macro_pluralization_visitor.rb', line 32 def track_method_renamed(from, to) @depth_visitor.track_method_renamed(from, to) end |
#track_method_undefined(name) ⇒ Object
28 29 30 |
# File 'lib/page_ez/visitors/macro_pluralization_visitor.rb', line 28 def track_method_undefined(name) @depth_visitor.track_method_undefined(name) end |