Sha256: 7f6e944421d4c56e941b966062216700f1af3629c9478ced9f47ccf658bfd223

Contents?: true

Size: 1.68 KB

Versions: 17

Compression:

Stored size: 1.68 KB

Contents

module Ridley
  class EnvironmentObject < Ridley::ChefObject
    set_chef_id "name"
    set_chef_type "environment"
    set_chef_json_class "Chef::Environment"

    attribute :name,
      required: true

    attribute :description,
      default: String.new

    attribute :default_attributes,
      default: Hashie::Mash.new

    attribute :override_attributes,
      default: Hashie::Mash.new

    attribute :cookbook_versions,
      default: Hashie::Mash.new

    # Set an environment level default attribute given the dotted path representation of
    # the Chef attribute and value
    #
    # @example setting and saving an environment level default attribute
    #
    #   obj = environment.find("production")
    #   obj.set_default_attribute("my_app.billing.enabled", false)
    #   obj.save
    #
    # @param [String] key
    # @param [Object] value
    #
    # @return [Hashie::Mash]
    def set_default_attribute(key, value)
      attr_hash = Hashie::Mash.from_dotted_path(key, value)
      self.default_attributes = self.default_attributes.deep_merge(attr_hash)
    end

    # Set an environment level override attribute given the dotted path representation of
    # the Chef attribute and value
    #
    # @example setting and saving an environment level override attribute
    #
    #   obj = environment.find("production")
    #   obj.set_override_attribute("my_app.billing.enabled", false)
    #   obj.save
    #
    # @param [String] key
    # @param [Object] value
    #
    # @return [Hashie::Mash]
    def set_override_attribute(key, value)
      attr_hash = Hashie::Mash.from_dotted_path(key, value)
      self.override_attributes = self.override_attributes.deep_merge(attr_hash)
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
ridley-1.6.0 lib/ridley/chef_objects/environment_object.rb
ridley-1.5.3 lib/ridley/chef_objects/environment_object.rb
ridley-1.2.6 lib/ridley/chef_objects/environment_object.rb
ridley-1.5.2 lib/ridley/chef_objects/environment_object.rb
ridley-1.5.1 lib/ridley/chef_objects/environment_object.rb
ridley-1.5.0 lib/ridley/chef_objects/environment_object.rb
ridley-1.2.5 lib/ridley/chef_objects/environment_object.rb
ridley-1.4.1 lib/ridley/chef_objects/environment_object.rb
ridley-1.4.0 lib/ridley/chef_objects/environment_object.rb
ridley-1.3.2 lib/ridley/chef_objects/environment_object.rb
ridley-1.3.1 lib/ridley/chef_objects/environment_object.rb
ridley-1.3.0 lib/ridley/chef_objects/environment_object.rb
ridley-1.2.4 lib/ridley/chef_objects/environment_object.rb
ridley-1.2.3 lib/ridley/chef_objects/environment_object.rb
ridley-1.2.2 lib/ridley/chef_objects/environment_object.rb
ridley-1.2.1 lib/ridley/chef_objects/environment_object.rb
ridley-1.2.0 lib/ridley/chef_objects/environment_object.rb