Module: Predicated::Predicate::TranslateToRubyString

Defined in:
lib/predicated/from/callable_object.rb

Class Method Summary collapse

Class Method Details

.convert(callable_object) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/predicated/from/callable_object.rb', line 29

def self.convert(callable_object)
  temp_class = Class.new
  temp_class.class_eval do
    define_method :serializable, &callable_object
  end
  ruby_code_string = Ruby2Ruby.translate(temp_class, :serializable)    
  ruby_code_string.sub(/^def serializable\n  /, "").sub(/\nend$/, "")
end