Sha256: 8320f97d89a9af2c7fe1fa90f5fad95371c5a75ea0665fa39b20a09adc44524f

Contents?: true

Size: 1.78 KB

Versions: 10

Compression:

Stored size: 1.78 KB

Contents

module Ridley
  # @author Jamie Winsor <reset@riotgames.com>
  class RoleResource < Ridley::Resource
    set_chef_id "name"
    set_chef_type "role"
    set_chef_json_class "Chef::Role"
    set_resource_path "roles"

    attribute :name,
      required: true

    attribute :description,
      default: String.new

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

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

    attribute :run_list,
      default: Array.new

    attribute :env_run_lists,
      default: Hash.new

    # Set a role level override attribute given the dotted path representation of the Chef
    # attribute and value
    # 
    # @example setting and saving a node level override attribute
    #
    #   obj = node.role("why_god_why")
    #   obj.set_override_attribute("my_app.billing.enabled", false)
    #   obj.save
    #
    # @param [String] key
    # @param [Object] value
    #
    # @return [HashWithIndifferentAccess]
    def set_override_attribute(key, value)
      attr_hash = HashWithIndifferentAccess.from_dotted_path(key, value)
      self.override_attributes = self.override_attributes.deep_merge(attr_hash)
    end

    # Set a role level default attribute given the dotted path representation of the Chef
    # attribute and value
    # 
    # @example setting and saving a node level default attribute
    #
    #   obj = node.role("why_god_why")
    #   obj.set_default_attribute("my_app.billing.enabled", false)
    #   obj.save
    #
    # @param [String] key
    # @param [Object] value
    #
    # @return [HashWithIndifferentAccess]
    def set_default_attribute(key, value)
      attr_hash = HashWithIndifferentAccess.from_dotted_path(key, value)
      self.default_attributes = self.default_attributes.deep_merge(attr_hash)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ridley-0.10.2 lib/ridley/resources/role_resource.rb
ridley-0.9.1 lib/ridley/resources/role_resource.rb
ridley-0.10.1 lib/ridley/resources/role_resource.rb
ridley-0.10.0 lib/ridley/resources/role_resource.rb
ridley-0.10.0.rc3 lib/ridley/resources/role_resource.rb
ridley-0.10.0.rc2 lib/ridley/resources/role_resource.rb
ridley-0.10.0.rc1 lib/ridley/resources/role_resource.rb
ridley-0.9.0 lib/ridley/resources/role_resource.rb
ridley-0.8.6 lib/ridley/resources/role_resource.rb
ridley-0.8.5 lib/ridley/resources/role_resource.rb