lib/xamplr/xampl-object.rb in xamplr-1.2.0 vs lib/xamplr/xampl-object.rb in xamplr-1.3.15

- old
+ new

@@ -126,10 +126,28 @@ return false if (defined? self._content) or (defined? other._content) end return true end + def indexed_by + nil + end + + def to_s + if self.persisted? then + "<<#{ self.class.name } #{ self.object_id } [#{ self.get_the_index }]#{ @is_changed ? ' DIRTY' : ''}>>" + elsif self.indexed_by then + "<<#{ self.class.name } #{ self.object_id } [#{ self.get_the_index }]>>" + else + "<<#{ self.class.name } #{ self.object_id }>>" + end + end + + def inspect + self.to_s + end + def to_ruby(mentions=nil) accessed return RubyPrinter.new(mentions).to_ruby(self) end @@ -181,10 +199,36 @@ def persist(out="", mentions=nil, rules=nil) persist_xml_new = PersistXML.new(out, mentions) return persist_xml_new.start(self).done end + ################################################################################################ + ################################################################################################ + ################################################################################################ + + def Xampl.find_things_to_delete(scheduled_before=Time.now.to_i) + things = Xampl.query do | q | + q.add_condition('scheduled-delete-at', :lte, scheduled_before) + end + things + end + + def should_schedule_delete? + #puts "Xampl#should_schedule_delete? is NOT IMPLEMENTED FOR: #{ self.class.name }" + false + end + + def schedule_a_deletion_if_needed(at=Time.now.to_i) + @scheduled_for_deletion_at = should_schedule_delete? ? at.to_s : nil #TODO -- necessary?? + end + + ################################################################################################ + ################################################################################################ + ################################################################################################ + + + def XamplObject.realise_from_xml_string(xml_string, target=nil, tokenise=true) xampl = FromXML.new.realise_string(xml_string, tokenise, target) return xampl end @@ -195,8 +239,15 @@ def XamplObject.from_xml_file(file_name, tokenise=true) return FromXML.new.parse(file_name, tokenise) end end + def Xampl.from_xml_string(xml_string, tokenise=true) + return FromXML.new.parse_string(xml_string, tokenise) + end + + def Xampl.from_xml_file(file_name, tokenise=true) + return FromXML.new.parse(file_name, tokenise) + end end