Sha256: 0089e0effbc706be063dc167f7a0b66af30857c853149894216f70aaa1be1eae

Contents?: true

Size: 669 Bytes

Versions: 15

Compression:

Stored size: 669 Bytes

Contents

module Contentful
  module Management
    module Resource
      # Mixin for environment aware resources
      module EnvironmentAware
        # Gets the environment ID for the resource.
        def environment_id
          env = sys.fetch(:environment, {})
          env_from_sys =
            case env
            when ::Hash
              env.fetch(:id, nil)
            when ::Contentful::Management::Link, ::Contentful::Management::Environment
              env.id
            end

          return env_from_sys if env_from_sys

          respond_to?(:content_type) && content_type && content_type.environment_id || 'master'
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
contentful-management-3.8.0 lib/contentful/management/resource/environment_aware.rb
contentful-management-3.7.0 lib/contentful/management/resource/environment_aware.rb
contentful-management-3.6.0 lib/contentful/management/resource/environment_aware.rb
contentful-management-3.5.0 lib/contentful/management/resource/environment_aware.rb
contentful-management-3.4.0 lib/contentful/management/resource/environment_aware.rb
contentful-management-3.3.0 lib/contentful/management/resource/environment_aware.rb
contentful-management-3.2.0 lib/contentful/management/resource/environment_aware.rb
contentful-management-3.1.0 lib/contentful/management/resource/environment_aware.rb
contentful-management-3.0.0 lib/contentful/management/resource/environment_aware.rb
contentful-management-2.13.1 lib/contentful/management/resource/environment_aware.rb
contentful-management-2.13.0 lib/contentful/management/resource/environment_aware.rb
contentful-management-2.12.1 lib/contentful/management/resource/environment_aware.rb
contentful-management-2.12.0 lib/contentful/management/resource/environment_aware.rb
contentful-management-2.11.0 lib/contentful/management/resource/environment_aware.rb
contentful-management-2.10.0 lib/contentful/management/resource/environment_aware.rb