lib/xamplr/xampl-object.rb in xamplr-1.9.0 vs lib/xamplr/xampl-object.rb in xamplr-1.9.1
- old
+ new
@@ -1,6 +1,5 @@
-
module Xampl
module XamplObject
attr_accessor :is_changed, :parents
@@ -132,11 +131,11 @@
nil
end
def to_s
if self.persisted? then
- "<<#{ self.class.name } #{ self.object_id } [#{ self.get_the_index }]#{ @is_changed ? ' DIRTY' : ''}>>"
+ "<<#{ 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
@@ -173,22 +172,13 @@
end
end
def XamplObject.from_string(string, target=nil)
return FromXML.new.parse_string(string, true, false, target)
-
- # if '<' == string[0] then
- # puts "XO.from_string XML ------------------------------------------------------"
- # return FromXML.new.parse_string(string, true, false, target)
- # else
- # puts "XO.from_string RUBY ------------------------------------------------------"
- # return XamplObject.from_ruby(string, target)
- # end
end
def XamplObject.recover_from_string(string)
- # return FromXML.new.realise_string(string)
return FromXML.new(true).parse_string(string, true, false, nil)
end
def XamplObject.from_ruby(ruby_string, target=nil)
eval(ruby_string, nil, "ruby_definition", 0)
@@ -223,31 +213,45 @@
################################################################################################
################################################################################################
################################################################################################
-
-
def XamplObject.realise_from_xml_string(xml_string, target=nil, tokenise=true)
xampl = FromXML.new.realise_string(xml_string, tokenise, target)
return xampl
end
+ def new_from_xml_string(xml_string, id=nil, tokenise=true)
+ thing = FromXML.new.parse_string(xml_string, tokenise)
+ if thing.indexed_by then
+ thing.set_the_index(id) if id
+ self << thing if thing.get_the_index
+ end
+ end
+
+ def new_from_xml_file(file_name, id=nil, tokenise=true)
+ thing = FromXML.new.parse(file_name, tokenise)
+ if thing.indexed_by then
+ thing.set_the_index(id) if id
+ self << thing if thing.get_the_index
+ end
+ end
+
def XamplObject.from_xml_string(xml_string, tokenise=true)
return FromXML.new.parse_string(xml_string, tokenise)
end
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_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
+ def Xampl.from_xml_file(file_name, tokenise=true)
+ return FromXML.new.parse(file_name, tokenise)
+ end
end