Class: OrientSupport::Hash

Inherits:
HashWithIndifferentAccess
  • Object
show all
Includes:
Support
Defined in:
lib/orient.rb

Instance Method Summary collapse

Methods included from Support

#compose_where, #generate_sql_list

Constructor Details

#initialize(modelinstance, args) ⇒ Hash

Returns a new instance of Hash.



111
112
113
114
115
116
117
118
119
120
# File 'lib/orient.rb', line 111

def initialize modelinstance, args
  @orient = modelinstance
  super args.from_orient
  # @name is the property of @orient to work on
  @name = modelinstance.attributes.key(self)
#      puts "ORIENT: #{@orient.inspect} "
  @name =  yield if @name.nil? && block_given?
#      puts "NAME: #{@name.inspect}"
#      puts "SELF: #{self.inspect}"
end

Instance Method Details

#[]=(key, value) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/orient.rb', line 123

def []=  key, value
  puts " i will handle this in the future"
#@orient.attributes[key] = value
  
# r = (@orient.query  "update #{@orient.rid} put #{@name} = #{key.to_orient}, #{value.to_orient} RETURN AFTER @this").pop
  super key, value
  @orient.update set:{ @name => self}
# @orient = @orient.class(@orient.rid){r} if r.is_a? ActiveOrient::Model
#  self[ key ]= value
#  puts self.inspect 
  #@orient[@name]=self.merge  key => value
  #
end

#delete(key) ⇒ Object



137
138
139
140
# File 'lib/orient.rb', line 137

def delete key
  super key
  @orient.update set:{ @name => self}
end

#delete_if(&b) ⇒ Object



142
143
144
145
146
# File 'lib/orient.rb', line 142

def delete_if &b
  super &b
  @orient.update set:{ @name => self}

end