class ActiveXML::Collection
Public Instance Methods
delete_nodes(keys)
click to toggle source
# File lib/active_xml/collection.rb, line 40 def delete_nodes(keys) keys.each { |key| xml.search(key).first.remove } end
pluck(key)
click to toggle source
# File lib/active_xml/collection.rb, line 6 def pluck(key) map do |elem| fetch_contents(elem.elements, key).first end end
split(route_path)
click to toggle source
# File lib/active_xml/collection.rb, line 17 def split(route_path) hash = Hash.new each do |elem| route = Route.new(route_path, elem) hashed_path = route.to_hash path = Pathname.new(hashed_path.values[0].join("/")) create_file(path, elem.to_xml) hash.merge!(hashed_path) { |key,old,new| old.class == Array ? old << new[0] : [new,old] } end hash end
split_to_array(route_path)
click to toggle source
# File lib/active_xml/collection.rb, line 31 def split_to_array(route_path) map do |elem| route = Route.new(route_path, elem) path = Pathname.new(route.generate) create_file(path, elem.to_xml) path end end
where(where_values)
click to toggle source
# File lib/active_xml/collection.rb, line 12 def where(where_values) raise ArgumentError.new("Passing more then 1 where value is currently not possible") if where_values.size > 1 Query.new(@path, where_values) end
Private Instance Methods
each(&block)
click to toggle source
# File lib/active_xml/collection.rb, line 50 def each(&block) xml.child.elements.each(&block) end
root()
click to toggle source
# File lib/active_xml/collection.rb, line 46 def root "objects" end