Sha256: 8c97db51032c533c3bcec7cacd86879c506e513552a6a19d14f37eb728647341

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

module ActiveOrient
  module Init

=begin
Parameters: yml: hash from config.yml , namespace: Class to use as Namespace
A custom Constant can be provided via Block

i.e.
  configyml =  YAML.load_file (...)  # with an entry "namespace:" 
  ActiveOrient.define_namespace yml: configyml 
  #or
  ActiveOrient.define_namespace namespace: :self | :object | :active_orient
  #or
  ActiveOrient.define_namespace { IB }  
=end
    def self.define_namespace  yml: {}, namespace: nil
      ActiveOrient::Model.namespace = if namespace.present? 
					namespace
				      elsif block_given?
					yield
				      else
					n= yml[:namespace].presence || :self
					case n
					when :self
					  ActiveOrient::Model
					when :object
					  Object
					when :active_orient
					  ActiveOrient
					end
				      end
      ## initialitze Edge and Vertex classes in the namespace
#      ActiveOrient::Model.orientdb_class( name:"E", superclass: "").new
#      ActiveOrient::Model.orientdb_class( name:"V", superclass: "").new
  end # define namespace


    def vertex_and_edge_class
      ORD.create_classes 'E', 'V'
      E.ref_name = 'E'
      V.ref_name = 'V'

    end
  end # module Init
end  # module ActiveOrient

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active-orient-0.6 lib/init.rb