Module: Contentful::Management::Resource::EnvironmentAware

Included in:
Asset, ContentType, EditorInterface, Entry, Locale, Snapshot, Tag, UIExtension
Defined in:
lib/contentful/management/resource/environment_aware.rb

Overview

Mixin for environment aware resources

Instance Method Summary collapse

Instance Method Details

#environment_idObject

Gets the environment ID for the resource.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/contentful/management/resource/environment_aware.rb', line 9

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