Skip to content

Commit 251c610

Browse files
author
Ilja Bobkevic
committed
Fix to_hash handling non builder objects
1 parent 4558918 commit 251c610

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/puppet_forge_server/models/builder.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ def method_missing (method_name, *args, &block)
2727
end
2828

2929
def to_hash(obj = self)
30+
# Quickly return if it's not one of ours
31+
unless obj.kind_of? Builder
32+
return obj
33+
end
34+
# Otherwise start building hash
3035
hash = {}
3136
obj.instance_variables.each do |var|
3237
var_value = obj.instance_variable_get(var)
@@ -41,4 +46,4 @@ def to_hash(obj = self)
4146
hash
4247
end
4348
end
44-
end
49+
end

0 commit comments

Comments
 (0)