module ResqueJobsTree::ResourcesSerializer

Public Instance Methods

argumentize(resources) click to toggle source

in: [<Localisation id=1>, :pdf] out: [[Localisation, 1], :pdf]

# File lib/resque_jobs_tree/resources_serializer.rb, line 6
def argumentize resources
  resources.to_a.map do |resource|
    resource.respond_to?(:id) ? [resource.class.name, resource.id] : resource
  end
end
instancize(args) click to toggle source

in: [['Localisation', 1], :pdf] out: [<Localisation id=1>, :pdf]

# File lib/resque_jobs_tree/resources_serializer.rb, line 14
def instancize args
  args.to_a.map do |arg|
    if arg.kind_of? Array
      eval(arg[0]).find(arg[1]) rescue arg
    else
      arg
    end
  end
end