lib/base_properties.rb in active-orient-0.79 vs lib/base_properties.rb in active-orient-0.80
- old
+ new
@@ -6,33 +6,34 @@
module BaseProperties
extend ActiveSupport::Concern
# Default presentation of ActiveOrient::Model-Objects
- def to_human
- "<#{self.class.to_s.demodulize}: " + content_attributes.map do |attr, value|
- v= case value
- when ActiveOrient::Model
- "< #{self.class.to_.demodulize} : #{value.rrid} >"
- when OrientSupport::Array
- value.rrid #.to_human #.map(&:to_human).join("::")
- else
- value.from_orient
- end
- "%s : %s" % [ attr, v] unless v.nil?
- end.compact.sort.join(', ') + ">".gsub('"' , ' ')
- end
+ def to_human
+ "<#{self.class.to_s.demodulize}: " + content_attributes.map do |attr, value|
+ v= case value
+ when ActiveOrient::Model
+ "< #{self.class.to_.demodulize} : #{value.rrid} >"
+ when OrientSupport::Array
+ value.rrid #.to_human #.map(&:to_human).join("::")
+ else
+ value.from_orient
+ end
+ "%s : %s" % [ attr, v] unless v.nil?
+ end.compact.sort.join(', ') + ">".gsub('"' , ' ')
+ end
# Comparison support
def content_attributes # :nodoc:
# HashWithIndifferentAccess[attributes.reject do |(attr, _)|
Hash[attributes.reject do |(attr, _)|
attr.to_s =~ /(_count)\z/ || attr.to_s =~ /^in_/ || attr.to_s =~ /^out_/ || [:created_at, :updated_at, :type, :id, :order_id, :contract_id].include?(attr.to_sym)
end]
end
-
# return a string ready to include as embedded document
+# used by Model.to_or
+#
def embedded
{ "@type" => 'd', "@class" => self.class.ref_name }
.merge(content_attributes)
.map{|y,x| z=''; z << y.to_s << ': ' << x.to_or.to_s }.join(' ,')