Class: DepsGrapher::AstProcessorPolicy
- Inherits:
-
Object
- Object
- DepsGrapher::AstProcessorPolicy
- Defined in:
- lib/deps_grapher/ast_processor_policy.rb
Instance Method Summary collapse
- #advanced_const_resolver(callable = nil, &block) ⇒ Object
- #const(matcher, &block) ⇒ Object
- #event_processor(matcher, prop, &block) ⇒ Object
- #exclude_const(matcher) ⇒ Object
- #exclude_location(matcher) ⇒ Object
- #include_const(matcher) ⇒ Object
- #include_location(matcher) ⇒ Object
-
#initialize(context, &block) ⇒ AstProcessorPolicy
constructor
A new instance of AstProcessorPolicy.
- #location(matcher, &block) ⇒ Object
Constructor Details
#initialize(context, &block) ⇒ AstProcessorPolicy
Returns a new instance of AstProcessorPolicy.
5 6 7 8 |
# File 'lib/deps_grapher/ast_processor_policy.rb', line 5 def initialize(context, &block) @context = context DSL.new(self).instance_eval(&block) end |
Instance Method Details
#advanced_const_resolver(callable = nil, &block) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/deps_grapher/ast_processor_policy.rb', line 38 def advanced_const_resolver(callable = nil, &block) raise ArgumentError, "You must provide a block or callable" unless block || callable raise ArgumentError, "The provided object must respond to #call" if callable && !callable.respond_to?(:call) @context.advanced_const_resolver = block || callable end |
#const(matcher, &block) ⇒ Object
10 11 12 |
# File 'lib/deps_grapher/ast_processor_policy.rb', line 10 def const(matcher, &block) event_processor matcher, :const_name, &block end |
#event_processor(matcher, prop, &block) ⇒ Object
34 35 36 |
# File 'lib/deps_grapher/ast_processor_policy.rb', line 34 def event_processor(matcher, prop, &block) @context.event_processors[matcher] = [prop, block] end |
#exclude_const(matcher) ⇒ Object
18 19 20 |
# File 'lib/deps_grapher/ast_processor_policy.rb', line 18 def exclude_const(matcher) const matcher, &:skip_processing! end |
#exclude_location(matcher) ⇒ Object
30 31 32 |
# File 'lib/deps_grapher/ast_processor_policy.rb', line 30 def exclude_location(matcher) location matcher, &:skip_processing! end |
#include_const(matcher) ⇒ Object
14 15 16 |
# File 'lib/deps_grapher/ast_processor_policy.rb', line 14 def include_const(matcher) const matcher, &:processing! end |
#include_location(matcher) ⇒ Object
26 27 28 |
# File 'lib/deps_grapher/ast_processor_policy.rb', line 26 def include_location(matcher) location matcher, &:processing! end |
#location(matcher, &block) ⇒ Object
22 23 24 |
# File 'lib/deps_grapher/ast_processor_policy.rb', line 22 def location(matcher, &block) event_processor matcher, :location, &block end |