Sha256: aca0f87f4c457abe89e6b5a06bffa55e11fd7f82fb6e85d19326d1ee603da563
Contents?: true
Size: 1006 Bytes
Versions: 62
Compression:
Stored size: 1006 Bytes
Contents
module Workarea class SaveTaxonomy def self.build(navigable) navigable.taxon || navigable.build_taxon( name: navigable.name, # These two fields necessary because Mongoid isn't setting them # automatically :( navigable_type: navigable.class.name, navigable_id: navigable.id ) end def initialize(taxon, params) @taxon = taxon @params = params end def perform @taxon.update_attributes!(parent_id: @params[:parent_id]) @taxon.move_to_position(@params[:position]) if @params[:position].present? set_taxonomy_slug end def set_taxonomy_slug Release.with_current(nil) do Sidekiq::Callbacks.disable(RedirectNavigableSlugs) do slug = FindTaxonomySlug.new(@taxon.navigable, @taxon).slug @taxon.navigable.update_attributes!(slug: slug) if slug.present? end end end def top_level? @taxon.parent == Navigation::Taxon.root end end end
Version data entries
62 entries across 62 versions & 1 rubygems