Class: Bran::Ext

Inherits:
Object
  • Object
show all
Defined in:
lib/bran/ext.rb

Constant Summary collapse

REGISTRY =
{}

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.check_assumptionsObject

Returns the value of attribute check_assumptions.



6
7
8
# File 'lib/bran/ext.rb', line 6

def check_assumptions
  @check_assumptions
end

Class Method Details

.[](ext_name) ⇒ Object



29
30
31
# File 'lib/bran/ext.rb', line 29

def [](ext_name)
  REGISTRY[ext_name]
end

.[]=(ext_name, value) ⇒ Object



25
26
27
# File 'lib/bran/ext.rb', line 25

def []=(ext_name, value)
  REGISTRY[ext_name] = value
end

.assume(&block) ⇒ Object



8
9
10
11
12
# File 'lib/bran/ext.rb', line 8

def assume(&block)
  return unless @check_assumptions
  
  instance_eval &block
end

.check(cond) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/bran/ext.rb', line 14

def check(cond)
  return if cond
  
  match = caller.first.match(/\A(.+?):(\d+):in/)
  line  = File.read(match[1]).each_line.to_a[Integer(match[2]) - 1].strip
  
  fail "Bran extension compatibility check failed: #{line}"
end