Sha256: 227b310cf46e473301a7957bce9499db19d77b54fb5503b82feaeffef412ff94

Contents?: true

Size: 769 Bytes

Versions: 1

Compression:

Stored size: 769 Bytes

Contents

module Qor
  module Dsl
    module ClassMethods
      def node_root
        @node_root ||= Qor::Dsl::Node.new
      end

      def node(type, options={}, &blk)
        node_root.node(type, options, &blk)
      end

      def root
        @root || load
      end

      def load(path=nil, opts={})
        @load_path = path || @load_path
        @root = (opts[:force] ? nil : @root) || load_file(@load_path)
        @root
      end

      def load_file(file)
        return unless File.exist?(file.to_s)
        content = File.read(file)
        node_root.config.instance_eval(content)
        node_root
      end

      def find(*arguments)
        root.find(*arguments)
      end

      def first(*arguments)
        root.first(*arguments)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
qor_dsl-0.0.1 lib/qor_dsl/class_method.rb