lib/cfndsl/names.rb in cfndsl-0.9.2 vs lib/cfndsl/names.rb in cfndsl-0.10.0
- old
+ new
@@ -1,18 +1,12 @@
# Method name helper
module CfnDsl
+ module_function
+
# iterates through the the valid case-insensitive names
# for "name"
- def self.method_names(name, &block)
- if block
- name_str = name.to_s
- yield name_str.to_sym
- n = name_str.dup
- n[0] = n[0].swapcase
- yield n.to_sym
- else
- result = [name.dup, name.dup]
- result[1][0] = result[1][0].swapcase
- return result
- end
+ def method_names(name)
+ name_str = name.to_s.dup
+ names = [name_str, name_str.gsub(/^\w/, &:swapcase)]
+ block_given? ? names.each { |n| yield n.to_sym } : names
end
end