Module: Trax::Core::IsolatedMixin
- Defined in:
- lib/trax/core/isolated_mixin.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #after_extended(&block) ⇒ Object
- #after_included(&block) ⇒ Object
- #included(base = nil, &block) ⇒ Object
- #mixed(&block) ⇒ Object
- #mixed_in(&block) ⇒ Object
- #on_concern_included(&block) ⇒ Object
Class Method Details
.extended(base) ⇒ Object
| 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | # File 'lib/trax/core/isolated_mixin.rb', line 31 def self.extended(base) base.extend(::ActiveSupport::Concern) base.extend(::Trax::Core::IsolatedMixin::ClassMethods) super(base) trace = ::TracePoint.new(:end) do |tracepoint| if tracepoint.self == base trace.disable if base.instance_variable_defined?(:@_after_extended_block) base.instance_variable_get(:@_after_extended_block).call end end end trace.enable end | 
Instance Method Details
#after_extended(&block) ⇒ Object
| 56 57 58 | # File 'lib/trax/core/isolated_mixin.rb', line 56 def after_extended(&block) self.instance_variable_set(:@_after_extended_block, block) end | 
#after_included(&block) ⇒ Object
| 60 61 62 | # File 'lib/trax/core/isolated_mixin.rb', line 60 def after_included(&block) self.instance_variable_set(:@_after_included_block, block) end | 
#included(base = nil, &block) ⇒ Object
| 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | # File 'lib/trax/core/isolated_mixin.rb', line 4 def included(base = nil, &block) unless base.respond_to?(:_concerns) base.class_attribute :_concerns_config base._concerns_confg = {} end base.extend(ClassMethods) super(base, &block) trace = ::TracePoint.new(:end) do |tracepoint| if tracepoint.self == base trace.disable if self.instance_variable_defined?(:@_after_included_block) base.instance_eval(&self.instance_variable_get(:@_after_included_block)) end if self.instance_variable_defined?(:@_on_concern_included_block) base.instance_exec(base._concerns_config[self.name.demodulize.underscore.to_sym], &self.instance_variable_get(:@_on_concern_included_block)) end end end trace.enable end | 
#mixed(&block) ⇒ Object
| 68 69 70 | # File 'lib/trax/core/isolated_mixin.rb', line 68 def mixed(&block) after_included(&block) end | 
#mixed_in(&block) ⇒ Object
| 64 65 66 | # File 'lib/trax/core/isolated_mixin.rb', line 64 def mixed_in(&block) after_included(&block) end | 
#on_concern_included(&block) ⇒ Object
| 72 73 74 | # File 'lib/trax/core/isolated_mixin.rb', line 72 def on_concern_included(&block) self.instance_variable_set(:@_on_concern_included_block, block) end |