Empact / roxml

ROXML is a module for binding Ruby classes to XML. It supports custom mapping and bidirectional marshalling between Ruby and XML using annotation-style class methods, via Nokogiri or LibXML.
http://roxml.rubyforge.org/
MIT License
223 stars 176 forks source link

Can't Marshal a ROXML object because of Proc variables #22

Closed findchris closed 14 years ago

findchris commented 14 years ago

Hi there.

Just recently, I started getting this error when trying to put my class in memcache: no marshal_dump is defined for class Proc

I inspected some of the objects, and sometimes an object does indeed contain a Proc. See below: @blocks=[#Proc:0x0197eff4@/path_to/gems/roxml-3.1.5/lib/roxml/definition.rb:186]

Is there anything I can do to eagerly call these procs to avoid this issue? Can you shed any light on what this variable is used for?

Cheers.

findchris commented 14 years ago

One more bit of info: I only started encountering this problem after I added another layer of XML nesting.

The modeling: class Activities include ROXML xml_accessor :activities, :as => [Activity] end

class Activity
  include ROXML
  xml_accessor :name
  xml_accessor :comment_engagement_datas, :as => [CommentEngagementData], :in => "recent_comment_engagement_datas"
end

class CommentEngagementData < EngagementData 
  include ROXML
  xml_accessor :name
end

class EngagementData
  include ROXML
  xml_accessor :created_at
  def initialize
    self.created_at = Time.now
  end
end

Could this have to do with the inheritance in the latter class? Is the Time.now reference triggering something in the CORE_BLOCK_SHORTHANDS logic?

Thanks again.

findchris commented 14 years ago

Just found this after stumbling across the History.txt: Default attrs ending in '_at' to DateTime. This can be overriden via :as

I believe I've isolated the problem, so opened a new issue and will close this one.

New issue lives here: http://github.com/Empact/roxml/issues/issue/23

-Chris

findchris commented 14 years ago

Closing.