~ubuntu-branches/ubuntu/wily/puppet/wily-proposed

« back to all changes in this revision

Viewing changes to lib/puppet/parser/resource.rb

  • Committer: Package Import Robot
  • Author(s): Stig Sandbeck Mathisen
  • Date: 2014-10-24 13:47:15 UTC
  • mfrom: (3.1.64 sid)
  • Revision ID: package-import@ubuntu.com-20141024134715-6ig54u0c4gar36ss
Tags: 3.7.2-1
* Imported upstream release 3.7.2
* Declare compliance with Debian Policy 3.9.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
162
162
  # if we ever receive a parameter named 'tag', set
163
163
  # the resource tags with its value.
164
164
  def set_parameter(param, value = nil)
165
 
    if ! value.nil?
 
165
    if ! param.is_a?(Puppet::Parser::Resource::Param)
166
166
      param = Puppet::Parser::Resource::Param.new(
167
167
        :name => param, :value => value, :source => self.source
168
168
      )
169
 
    elsif ! param.is_a?(Puppet::Parser::Resource::Param)
170
 
      raise ArgumentError, "Received incomplete information - no value provided for parameter #{param}"
171
169
    end
172
170
 
173
171
    tag(*param.value) if param.name == :tag
180
178
  def to_hash
181
179
    @parameters.inject({}) do |hash, ary|
182
180
      param = ary[1]
183
 
      # Skip "undef" values.
184
 
      hash[param.name] = param.value if param.value != :undef
 
181
      # Skip "undef" and nil values.
 
182
      hash[param.name] = param.value if param.value != :undef && !param.value.nil?
185
183
      hash
186
184
    end
187
185
  end
191
189
    copy_as_resource.to_ral
192
190
  end
193
191
 
 
192
  # Is the receiver tagged with the given tags?
 
193
  # This match takes into account the tags that a resource will inherit from its container
 
194
  # but have not been set yet.
 
195
  # It does *not* take tags set via resource defaults as these will *never* be set on
 
196
  # the resource itself since all resources always have tags that are automatically
 
197
  # assigned.
 
198
  #
 
199
  def tagged?(*tags)
 
200
    super || ((scope_resource = scope.resource) && scope_resource != self && scope_resource.tagged?(tags))
 
201
  end
 
202
 
194
203
  private
195
204
 
196
205
  # Add default values from our definition.
227
236
        msg += " at #{fields.join(":")}"
228
237
      end
229
238
      msg += "; cannot redefine"
230
 
      Puppet.log_exception(ArgumentError.new(), msg)
231
239
      raise Puppet::ParseError.new(msg, param.line, param.file)
232
240
    end
233
241