module Cube::CubeMethods

Public Instance Methods

as_interface(iface, runtime_checks: true) click to toggle source
# File lib/cube/toplevel.rb, line 77
def as_interface(iface, runtime_checks: true)
  raise ArgumentError, "#{iface} is not a Cube::Interface" unless iface.is_a?(Cube::Interface)
  implements = lambda { |this|
    unless this.is_a? Class
      raise "Non-Class modules cannot implement interfaces"
    end
    this.instance_variable_set(:@__interface_runtime_check, true) if runtime_checks
    this.include(iface)
  }
  implements.call(clone)
end
shell_implements(mod) click to toggle source
# File lib/cube/toplevel.rb, line 90
def shell_implements(mod)
  instance_variable_set(:@__interface_runtime_check, false)
  instance_variable_set(:@__interface_arity_skip, true)
  include(mod)
end