module Mountapi module Route # The handler is called if the route match # Handler data should be any string representation of callable class Handler def initialize(callable) self.callable = callable end def callable=(callable) @callable ||= if callable.respond_to? :call callable elsif callable.kind_of?(String) eval(callable) else raise ArgumentError, "invalid callable: #{callable}" end end def raw_value @callable end def call(*params) @callable.call(*params) end end end end