Sha256: aa0d8b0992c5c1334fa33ecc5e81358d4daccd6750bc985a73cc083af8752454

Contents?: true

Size: 1.02 KB

Versions: 53

Compression:

Stored size: 1.02 KB

Contents

module Locomotive::Steam
  module Adapters
    module Filesystem

      module Sanitizer

        extend Forwardable

        def_delegators :@scope, :site, :locale, :locales, :default_locale

        attr_reader :scope

        def setup(scope)
          @scope = scope
          self
        end

        def with(scope, &block)
          setup(scope)
          yield(self)
        end

        def apply_to(entity_or_dataset)
          if entity_or_dataset.respond_to?(:all)
            apply_to_dataset(entity_or_dataset)
          else
            apply_to_entity(entity_or_dataset)
          end
        end

        def apply_to_dataset(dataset)
          dataset
        end

        def apply_to_entity(entity)
          attach_site_to(entity)
          entity
        end

        def apply_to_entity_with_dataset(entity, dataset)
          entity
        end

        def attach_site_to(entity)
          entity[:site_id] = scope.site._id if scope.site
        end

        alias :current_locale :locale

      end

    end
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
locomotivecms_steam-1.8.0.alpha2 lib/locomotive/steam/adapters/filesystem/sanitizer.rb
locomotivecms_steam-1.8.0.alpha1 lib/locomotive/steam/adapters/filesystem/sanitizer.rb
locomotivecms_steam-1.7.1 lib/locomotive/steam/adapters/filesystem/sanitizer.rb
locomotivecms_steam-1.7.0 lib/locomotive/steam/adapters/filesystem/sanitizer.rb
locomotivecms_steam-1.6.1 lib/locomotive/steam/adapters/filesystem/sanitizer.rb
locomotivecms_steam-1.6.0 lib/locomotive/steam/adapters/filesystem/sanitizer.rb
locomotivecms_steam-1.6.0.rc1 lib/locomotive/steam/adapters/filesystem/sanitizer.rb
locomotivecms_steam-1.6.0.beta1 lib/locomotive/steam/adapters/filesystem/sanitizer.rb
locomotivecms_steam-1.5.3 lib/locomotive/steam/adapters/filesystem/sanitizer.rb
locomotivecms_steam-1.5.2 lib/locomotive/steam/adapters/filesystem/sanitizer.rb
locomotivecms_steam-1.5.1 lib/locomotive/steam/adapters/filesystem/sanitizer.rb
locomotivecms_steam-1.5.0 lib/locomotive/steam/adapters/filesystem/sanitizer.rb
locomotivecms_steam-1.5.0.rc1 lib/locomotive/steam/adapters/filesystem/sanitizer.rb
locomotivecms_steam-1.5.0.rc0 lib/locomotive/steam/adapters/filesystem/sanitizer.rb
locomotivecms_steam-1.5.0.beta3 lib/locomotive/steam/adapters/filesystem/sanitizer.rb
locomotivecms_steam-1.5.0.beta2 lib/locomotive/steam/adapters/filesystem/sanitizer.rb
locomotivecms_steam-1.4.1 lib/locomotive/steam/adapters/filesystem/sanitizer.rb
locomotivecms_steam-1.4.0 lib/locomotive/steam/adapters/filesystem/sanitizer.rb
locomotivecms_steam-1.4.0.rc2 lib/locomotive/steam/adapters/filesystem/sanitizer.rb
locomotivecms_steam-1.4.0.rc1 lib/locomotive/steam/adapters/filesystem/sanitizer.rb