Sha256: a4ea0abc4864afd805490abbd6c4e8ca06dc5a83e2b8a1c18e4355d6925a2068

Contents?: true

Size: 703 Bytes

Versions: 1

Compression:

Stored size: 703 Bytes

Contents

module Cadet
  class DSL
    def initialize(db)
      @db = db
    end

    def method_missing(name, *args, &block)
      case name
        when /^([A-z_]*)_by_([A-z_]*)$/
            self.class.class_eval "
              def #{name}(value)
                @db.get_node :#{$1}, :#{$2}, value
              end"
            return self.send(name, *args, &block)

        when /^create_([A-z_]*)$/
          self.class.class_eval "
            def #{name}(value, indexing_property = nil)
              @db.create_node :#{$1}, value, indexing_property
            end"
          return self.send(name, *args, &block)
        else
          return @db.send(name, *args, &block)
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cadet-0.0.9-java lib/cadet/dsl.rb