lib/contentful/management/resource/environment_aware.rb in contentful-management-2.9.1 vs lib/contentful/management/resource/environment_aware.rb in contentful-management-2.10.0

- old
+ new

@@ -4,17 +4,20 @@ # Mixin for environment aware resources module EnvironmentAware # Gets the environment ID for the resource. def environment_id env = sys.fetch(:environment, {}) - case env - when ::Hash - env.fetch(:id, 'master') - when ::Contentful::Management::Link - env.id - else - 'master' - end + 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