Sha256: 774b667e3221bb41d57c4742774e9d3e12a44d819331e66941d7edecda6ec63f

Contents?: true

Size: 1.66 KB

Versions: 52

Compression:

Stored size: 1.66 KB

Contents

module Ridley
  class RoleObject < Ridley::ChefObject
    set_chef_id "name"
    set_chef_type "role"
    set_chef_json_class "Chef::Role"

    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 [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

    # 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 [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
  end
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
ridley-3.0.0 lib/ridley/chef_objects/role_object.rb
ridley-3.0.0.rc1 lib/ridley/chef_objects/role_object.rb
ridley-2.5.1 lib/ridley/chef_objects/role_object.rb
ridley-2.5.0 lib/ridley/chef_objects/role_object.rb
ridley-2.4.4 lib/ridley/chef_objects/role_object.rb
ridley-2.4.3 lib/ridley/chef_objects/role_object.rb
ridley-2.4.2 lib/ridley/chef_objects/role_object.rb
ridley-2.4.1 lib/ridley/chef_objects/role_object.rb
ridley-2.4.0 lib/ridley/chef_objects/role_object.rb
ridley-2.3.0 lib/ridley/chef_objects/role_object.rb
ridley-2.2.0 lib/ridley/chef_objects/role_object.rb
ridley-2.1.0 lib/ridley/chef_objects/role_object.rb
ridley-2.0.0 lib/ridley/chef_objects/role_object.rb
ridley-1.7.1 lib/ridley/chef_objects/role_object.rb
ridley-1.7.0 lib/ridley/chef_objects/role_object.rb
ridley-1.6.0 lib/ridley/chef_objects/role_object.rb
ridley-1.5.3 lib/ridley/chef_objects/role_object.rb
ridley-1.2.6 lib/ridley/chef_objects/role_object.rb
ridley-1.5.2 lib/ridley/chef_objects/role_object.rb
ridley-1.5.1 lib/ridley/chef_objects/role_object.rb