Module: Yogo::Operation::Restricted::Construction

Defined in:
lib/yogo/operation/restricted/construction.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



7
8
9
# File 'lib/yogo/operation/restricted/construction.rb', line 7

def self.included(base)
  raise "Inclusions not allowed. Use: extend(#{self.name})"
end

Instance Method Details

#extended(base) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/yogo/operation/restricted/construction.rb', line 11

def extended(base)
  base.class_eval {
    include ExpectedType
  }
  base.instance_eval {
    protected :new
  }
end

#on(type, &block) ⇒ Object



20
21
22
23
24
# File 'lib/yogo/operation/restricted/construction.rb', line 20

def on(type, &block)
  op = self.new(&block)
  op.instance_eval{ self.expected_type = type }
  op
end