Skip to content

Need to convert strings and fixnums to arrays #367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 17, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/puppet/parser/functions/member.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
module Puppet::Parser::Functions
newfunction(:member, :type => :rvalue, :doc => <<-EOS
This function determines if a variable is a member of an array.
The variable can either be a string or an array.
The variable can be a string, fixnum, or array.

*Examples:*

Expand Down Expand Up @@ -39,7 +39,11 @@ module Puppet::Parser::Functions
raise(Puppet::ParseError, 'member(): Requires array to work with')
end

if arguments[1].is_a? String
unless arguments[1].is_a? String or arguments[1].is_a? Fixnum or arguments[1].is_a? Array
raise(Puppet::ParseError, 'member(): Item to search for must be a string, fixnum, or array')
end

if arguments[1].is_a? String or arguments[1].is_a? Fixnum
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line of documentation is now out of date:
The variable can either be a string or an array.

Also, it might be useful to raise when a string, number or array isn't passed as the second argument (what happens when a hash is passed, or undef (is it represented as a symbol)?

item = Array(arguments[1])
else
item = arguments[1]
Expand Down