class Relaxo::QueryServer::Library
Public Class Methods
for(root, path)
click to toggle source
# File lib/relaxo/query_server/library.rb, line 24 def self.for(root, path) parent = root path = path.split('/') unless Array === path library = path.inject(parent) do |current, name| return nil if current == nil parent = current current[name] end return nil if library == nil unless Library === library library = parent[path.last] = Library.new(root, path, library) end return library.instance end
load(path)
click to toggle source
# File lib/relaxo/query_server/library.rb, line 66 def self.load(path) Library.for(root, path) end
new(root, path, code)
click to toggle source
# File lib/relaxo/query_server/library.rb, line 46 def initialize(root, path, code) @root = root @path = path @code = code @klass = nil @instance = nil end
root()
click to toggle source
# File lib/relaxo/query_server/library.rb, line 62 def self.root self.const_get(:ROOT) end
Public Instance Methods
instance()
click to toggle source
# File lib/relaxo/query_server/library.rb, line 55 def instance unless @klass @klass = Class.new @klass.const_set(:ROOT, @root) # Not sure if this is the best way to implement the `load` function @klass.class_eval do def self.root self.const_get(:ROOT) end def self.load(path) Library.for(root, path) end def load(path) self.class.load(path) end end @klass.class_eval @code, @path.join('/') end @instance ||= @klass.new end
load(path)
click to toggle source
# File lib/relaxo/query_server/library.rb, line 70 def load(path) self.class.load(path) end