Class: Contracts::Engine::Eigenclass
- Defined in:
- lib/contracts/engine/eigenclass.rb
Overview
Special case of contracts engine for eigenclasses We don’t care about eigenclass of eigenclass at this point
Instance Attribute Summary collapse
-
#owner_class ⇒ Object
Class that owns this eigenclass.
Class Method Summary collapse
-
.lift(eigenclass, owner) ⇒ Engine::Eigenclass
Automatically enables eigenclass engine if it is not Returns its engine NOTE: Required by jruby in 1.9 mode.
Instance Method Summary collapse
-
#all_decorators ⇒ Object
Fetches just eigenclasses decorators.
-
#set_eigenclass_owner ⇒ Object
No-op for eigenclasses.
Methods inherited from Base
#add_method_decorator, applied?, apply, #decorate, #decorated_methods?, #decorated_methods_for, fetch_from, #initialize, #nearest_decorated_ancestor
Constructor Details
This class inherits a constructor from Contracts::Engine::Base
Instance Attribute Details
#owner_class ⇒ Object
Class that owns this eigenclass
9 10 11 |
# File 'lib/contracts/engine/eigenclass.rb', line 9 def owner_class @owner_class end |
Class Method Details
.lift(eigenclass, owner) ⇒ Engine::Eigenclass
Automatically enables eigenclass engine if it is not Returns its engine NOTE: Required by jruby in 1.9 mode. Otherwise inherited eigenclasses don’t have their engines
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/contracts/engine/eigenclass.rb', line 19 def self.lift(eigenclass, owner) return Engine.fetch_from(eigenclass) if Engine.applied?(eigenclass) Target.new(eigenclass).apply(Eigenclass) eigenclass.extend(MethodDecorators) # FIXME; this should detect what user uses `include Contracts` or # `include Contracts;;Core` eigenclass.send(:include, Contracts) Engine.fetch_from(owner).set_eigenclass_owner Engine.fetch_from(eigenclass) end |
Instance Method Details
#all_decorators ⇒ Object
Fetches just eigenclasses decorators
35 36 37 |
# File 'lib/contracts/engine/eigenclass.rb', line 35 def all_decorators pop_decorators end |
#set_eigenclass_owner ⇒ Object
No-op for eigenclasses
32 |
# File 'lib/contracts/engine/eigenclass.rb', line 32 def set_eigenclass_owner; end |