lib/orient.rb in active-orient-0.5 vs lib/orient.rb in active-orient-0.6
- old
+ new
@@ -33,15 +33,12 @@
=begin
Append the argument to the Array, changes the Array itself.
The change is transmitted to the database immediately
=end
- def << arg
-# print "\n <<---> #{@name}, #{arg} <--- \n"
- if @name.present?
- @orient.add_item_to_property(@name, arg)
- end
+ def << *arg
+ @orient.add_item_to_property(@name, *arg) if @name.present?
super
end
=begin
Updating of single items
@@ -52,37 +49,36 @@
def []= key, value
super
@orient.update set: {@name => self} if @name.present?
end
- def [] *arg
- super
+# def [] *arg
+# #puts "ARG #{arg}"
+# super
+# end
+#
+=begin
+Remove_at performs Array#delete_at
+=end
+ def remove_at *pos
+ @orient.remove_position_from_property(@name,*pos) if @name.present?
end
- def delete_at *pos
- if @name.present?
- delete self[*pos]
- else
- super
- end
- end
+#
+# alias :del_org :delete
+=begin
+Remove performs Array#delete
- def delete_if
- if @name.present?
- delete *self.map{|y| y if yield(y)}.compact # if the block returns true then delete the item
- else
- super
- end
+If the Array-element is a link, this is removed, the linked table is untouched
+=end
+ def remove *item
+ @orient.remove_item_from_property(@name,*item) if @name.present?
end
-
- def delete *item
- @orient.remove_item_from_property(@name){item} if @name.present?
- end
-
+###
## just works with Hashes as parameters
def where *item
- where_string = item.map{|m| where_string = compose_where m}.join(' and ')
+ where_string = item.map{|m| where_string = compose_where( m ) }.join(' and ')
subquery= OrientSupport::OrientQuery.new from: @orient, projection: "expand( #{@name})"
q= OrientSupport::OrientQuery.new from: subquery, where: item
# query = "SELECT FROM ( SELECT EXPAND( #{@name} ) FROM #{@orient.classname}) #{where_string} "
# puts q.compose
# sql_cmd = -> (command) {{ type: "cmd", language: "sql", command: command }}
@@ -91,16 +87,15 @@
# end
@orient.query q
end
def method_missing *args
- begin
- map{|x| x.send args.first}
+
+ map{|x| x.send *args }
rescue NoMethodError => e
logger.progname = "OrientSupport::Array#MethodMissing"
logger.error{"Undefined method: #{e.message}"}
- end
end
end #Class
class LinkMap < OrientSupport::Array
@@ -148,13 +143,9 @@
super &b
@orient.update set:{ @name => self}
end
-# def <<
-
-
-# def to_orient
# self
# end
end
end #Module