orbit-basic/app/models/preview.rb

26 lines
645 B
Ruby
Raw Normal View History

class Preview
include Mongoid::Document
include Mongoid::Timestamps
field :object, :type => Hash
field :preview_at_link
field :expired_at , :type => DateTime
field :link_args, :type => Array
field :object_class_type
def get_arg_hash
object.slice(*link_args).inject({}){|la,(k,v)| la[k.to_sym] = v; la}
end
def get_preview_link
ap = Rails.application.routes.url_helpers
ap.send preview_at_link,({:id=>id,:preview=>true}.merge get_arg_hash)
#func = eval("Rails.application.routes.url_helpers.#{preview_at_link}").send
end
def get_virtual_object
eval(self.object_class_type).new object
end
end