Class: BetterRailsDebugger::Parser::Ruby::Extension
- Inherits:
-
Object
- Object
- BetterRailsDebugger::Parser::Ruby::Extension
- Defined in:
- lib/better_rails_debugger/parser/ruby/extension.rb,
lib/better_rails_debugger/parser/ruby/module_detector.rb
Direct Known Subclasses
Constant Summary collapse
- @@classes =
Hash.new(ActiveSupport::HashWithIndifferentAccess.new)
Class Method Summary collapse
- .config_for(klass) ⇒ Object
-
.name(extension_name) ⇒ Object
Define the name of the extension.
-
.position(position) ⇒ Object
Define the position of the extension.
- .sorted_extensions ⇒ Object
Instance Method Summary collapse
-
#initialize(processor) ⇒ Extension
constructor
A new instance of Extension.
- #run ⇒ Object
- #setup ⇒ Object
Constructor Details
#initialize(processor) ⇒ Extension
Returns a new instance of Extension.
31 32 33 |
# File 'lib/better_rails_debugger/parser/ruby/extension.rb', line 31 def initialize(processor) @processor = processor end |
Class Method Details
.config_for(klass) ⇒ Object
19 20 21 |
# File 'lib/better_rails_debugger/parser/ruby/extension.rb', line 19 def self.config_for(klass) @@classes[klass] end |
.name(extension_name) ⇒ Object
Define the name of the extension.
14 15 16 17 |
# File 'lib/better_rails_debugger/parser/ruby/extension.rb', line 14 def self.name(extension_name) raise ArgumentError.new "Argument must define to_s method" unless extension_name.respond_to? :to_s @@classes[self.class][:name] = extension_name.to_s end |
.position(position) ⇒ Object
Define the position of the extension. The position define when should be executed, if for example we have Ext1 and Ext2, with position 2 and 1, then Ext2 it’s going to be executed before Ext1. This is useful for an extension that depends of another one
7 8 9 10 11 |
# File 'lib/better_rails_debugger/parser/ruby/extension.rb', line 7 def self.position(position) # TODO: Allow to set position before another extension of after that one raise ArgumentError.new "Expected Integer or Float" unless position.kind_of? Integer or position.kind_of? Float @@classes[self.class][:position] = position end |
.sorted_extensions ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/better_rails_debugger/parser/ruby/extension.rb', line 23 def self.sorted_extensions ::BetterRailsDebugger::Parser::Ruby::Extension.descendants.sort_by do |klass| config = config_for klass # Classes without position goes at bottom config[:position] || Float::INFINITY end end |
Instance Method Details
#run ⇒ Object
39 40 41 |
# File 'lib/better_rails_debugger/parser/ruby/extension.rb', line 39 def run() raise ScriptError.new "Please, define run method" end |
#setup ⇒ Object
35 36 37 |
# File 'lib/better_rails_debugger/parser/ruby/extension.rb', line 35 def setup end |