Class: CanTango::Ability::Cache::Kompiler

Inherits:
Object
  • Object
show all
Defined in:
lib/cantango/ability/cache/kompiler.rb

Defined Under Namespace

Classes: CacheMarshallError

Instance Method Summary collapse

Instance Method Details

#compile!(rules_raw) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/cantango/ability/cache/kompiler.rb', line 9

def compile! rules_raw
  return if !rules_raw
  rules_compiled = rules_raw.map do |rule|
    rule.block = rule.block.to_source if rule.block.class == Proc && sourcify?
    rule
  end
end

#decompile!(rules_compiled) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/cantango/ability/cache/kompiler.rb', line 17

def decompile! rules_compiled
  return if !rules_compiled
  rules_raw = rules_compiled.map do |rule|
    compiler_check! rule
    rule.block = eval("#{rule.block}") if sourcify?
    rule
  end
end