Last active
December 19, 2015 08:09
-
-
Save Raven24/5923313 to your computer and use it in GitHub Desktop.
diaspora xml dumps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Diaspora::Federated::Base::InstanceMethods | |
alias_method :old_to_diaspora_xml, :to_diaspora_xml | |
def to_diaspora_xml | |
filename = tmp_dump_path.join("#{self.class.name}.xml") | |
File.open(filename, 'a') { |file| file.write(to_xml.to_s) } | |
old_to_diaspora_xml | |
end | |
def tmp_dump_path | |
return @tmp_dump_path unless @tmp_dump_path.nil? | |
@tmp_dump_path = Rails.root.join('tmp','xml_dumps') | |
@tmp_dump_path.mkpath unless @tmp_dump_path.exist? | |
@tmp_dump_path | |
end | |
end | |
### OR | |
Dir[Rails.root.join('app/models/*.rb').to_s].each do |f| | |
klass = File.basename(f, '.rb').camelize.constantize | |
next unless klass.ancestors.include?(ROXML) | |
puts "\n\n#{klass.name}" | |
klass.roxml_attrs.each { |attr| puts "-- #{attr.name} => #{attr.sought_type} #{attr.array? ? '(Array)' : ''}" } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment