Sha256: 86c3a9fa2e1127e608a8248fc06369cc71083d99c5dafae53152f8164895fd35

Contents?: true

Size: 592 Bytes

Versions: 4

Compression:

Stored size: 592 Bytes

Contents

module Locomotive::Steam
  module Models

    class Scope

      attr_accessor :site, :locale, :context

      def initialize(site, locale, context = nil)
        @site, @locale, @context = site, locale, (context || {})
      end

      def default_locale
        site.try(:default_locale)
      end

      def locales
        site.try(:locales)
      end

      def to_key
        (@site ? ['site', @site._id] : []).tap do |base|
          @context.each do |name, object|
            base << [name, object.try(:_id)]
          end
        end.flatten.join('_')
      end

    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
locomotivecms_steam-1.0.0.pre.alpha.3 lib/locomotive/steam/models/scope.rb
locomotivecms_steam-1.0.0.pre.alpha.2 lib/locomotive/steam/models/scope.rb
locomotivecms_steam-1.0.0.pre.alpha.1 lib/locomotive/steam/models/scope.rb
locomotivecms_steam-1.0.0.pre.alpha lib/locomotive/steam/models/scope.rb