Sha256: ba56ff568e8c5bc810f5672ee82c890c1c23835ecc749e6c52afcbba27f90352

Contents?: true

Size: 1.2 KB

Versions: 3

Compression:

Stored size: 1.2 KB

Contents

module OrientDbPrivate
	private

	def translate_property_hash field, type: nil, linked_class: nil, **args
		type =  type.presence || args[:propertyType].presence || args[:property_type]
		linked_class = linked_class.presence || args[:linkedClass] || args[:other_class]
		if type.present?
		  if linked_class.nil?
		    {field => {propertyType: type.to_s.upcase}}
		  else
		    {field => {propertyType: type.to_s.upcase, linkedClass: classname(linked_class)}}
		  end
		end
	end

	 def property_uri this_classname
	   if block_given?
	     "property/#{@database}/#{this_classname}/" << yield
	   else
	     "property/#{@database}/#{this_classname}"
	   end
	 end
	
	 def self.simple_uri *names
	   names.each do |name|
	     m_name = ("#{name.to_s}_uri").to_sym
	     define_method(m_name) do |&b|
	       if b
	         "#{name.to_s}/#{@database}/#{b.call}"
	       else
	         "#{name.to_s}/#{@database}"
	       end # branch
	     end
	   end
	 end
	
	 def self.sql_uri *names
	   names.each do |name|
	     define_method(("#{name.to_s}_sql_uri").to_sym) do
	       "#{name.to_s}/#{@database}/sql/"
	     end
	   end
	 end
	
	 simple_uri :database, :document, :class, :batch, :function
	 sql_uri :command, :query

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active-orient-0.80 lib/orientdb_private.rb
active-orient-0.79 lib/orientdb_private.rb
active-orient-0.6 lib/orientdb_private.rb