lib/rooftop/resource_links/link.rb in rooftop-0.1.4 vs lib/rooftop/resource_links/link.rb in rooftop-0.1.4.1
- old
+ new
@@ -1,12 +1,25 @@
module Rooftop
module ResourceLinks
class Link < ::OpenStruct
attr_accessor :link_type
+
def initialize(link_type,args, klass=nil)
@link_type = link_type
@mapped_class = klass.try(:resource_link_mapping).try(:[],@link_type)
+ @klass = klass
+
super(args)
+ end
+
+ def marshal_dump
+ [@link_type, @table, @klass]
+ end
+
+ def marshal_load(array)
+ @link_type = array[0]
+ @table = array[1]
+ @klass = array[2]
end
def resolve(klass=nil)
# We need to figure out what we're going to instantiate. If it's in the resource link mapping, use that. If not, try the klass passed into the resolve() method. Failing that, make an attempt to constantize something; otherwise we're going to have to raise
@mapped_class ||= klass || @link_type.camelize.classify.constantize