Class: Ree::ImportDsl
Defined Under Namespace
Classes: ClassConstant, RemovedConstant, UnlinkConstError
Instance Method Summary collapse
- #execute(klass, proc) ⇒ Object
-
#initialize ⇒ ImportDsl
constructor
A new instance of ImportDsl.
Constructor Details
#initialize ⇒ ImportDsl
Returns a new instance of ImportDsl.
4 5 6 |
# File 'lib/ree/dsl/import_dsl.rb', line 4 def initialize setup_removed_constants end |
Instance Method Details
#execute(klass, proc) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ree/dsl/import_dsl.rb', line 8 def execute(klass, proc) class_constant = self.class.instance_exec(&proc) [ extract_constants(class_constant), get_removed_constants ] rescue Ree::ImportDsl::UnlinkConstError => e retry_after = remove_or_assign_const(klass, e.const) retry if retry_after rescue NoMethodError => e if e.name == :& || e.name == :as retry_after = remove_or_assign_const(klass, e.receiver) retry if retry_after else raise e end rescue NameError => e proc .binding .eval("#{e.name} = Ree::ImportDsl::ClassConstant.new('#{e.name}')") retry end |