lib/lunanode/action_generator.rb in lunanode-0.1.5 vs lib/lunanode/action_generator.rb in lunanode-0.1.6
- old
+ new
@@ -19,11 +19,11 @@
def generate_default_modules
generate_categories(api_data)
end
- UNSAFE_IDENTIFIER = /.{21,}|[^A-Za-z0-9_*]/
+ UNSAFE_IDENTIFIER = /.{21,}|[^A-Za-z0-9_*\-]/
def module_name(name)
if name.length > 3
name.capitalize
else
@@ -91,11 +91,11 @@
unless param_list.empty?
param_list_call = ", #{param_list_call_arr.join(', ')}"
param_list_sig = "(#{param_list_sig_arr.join(', ')})"
end
- "def #{category}_#{action}#{param_list_sig}\n" \
- " action(:#{category}, :#{action}#{param_list_call})\n" \
+ "def #{category}_#{action.to_s.tr('-', '_')}#{param_list_sig}\n" \
+ " action(:#{category}, #{action.inspect}#{param_list_call})\n" \
"end\n"
end
private_constant :UNSAFE_IDENTIFIER
private_class_method :check_safe!, :generate_categories, :generate_actions,