Module: OrientDB::AR::DocumentMixin::ClassMethods
- Defined in:
- lib/orientdb-ar/document_mixin.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #field(name, type, options = { }) ⇒ Object
- #from_orientdb(value) ⇒ Object
- #new_document ⇒ Object
- #to_orientdb(value) ⇒ Object
Instance Attribute Details
#oclass_name ⇒ Object
112 113 114 |
# File 'lib/orientdb-ar/document_mixin.rb', line 112 def oclass_name @oclass_name ||= name.to_s.gsub('::', '__') end |
Instance Method Details
#field(name, type, options = { }) ⇒ Object
116 117 118 119 120 121 122 123 |
# File 'lib/orientdb-ar/document_mixin.rb', line 116 def field(name, type, = { }) name = name.to_sym if fields.key? name puts "Already defined field [#{name}]" else fields[name] = { :type => type }.update end end |
#from_orientdb(value) ⇒ Object
129 130 131 |
# File 'lib/orientdb-ar/document_mixin.rb', line 129 def from_orientdb(value) value.respond_to?(:to_orientdb_ar) ? value.to_orientdb_ar : value end |
#new_document ⇒ Object
125 126 127 |
# File 'lib/orientdb-ar/document_mixin.rb', line 125 def new_document OrientDB::Document.new connection, oclass_name end |
#to_orientdb(value) ⇒ Object
133 134 135 136 137 138 139 140 141 |
# File 'lib/orientdb-ar/document_mixin.rb', line 133 def to_orientdb(value) if value.respond_to?(:to_orientdb) value.to_orientdb elsif value.respond_to?(:jruby_value) value.jruby_value else value end end |