Move template to external file

This commit is contained in:
Rafa de la Torre
2015-11-18 15:00:47 +01:00
parent 584a76b927
commit 0f953dd5b6
2 changed files with 4 additions and 4 deletions
+3 -4
View File
@@ -9,18 +9,17 @@ GEOCODER_CLIENT_SCHEMA = 'cdb_geocoder_client'
INTERFACE_SOURCE_FILE = 'interface.csv' INTERFACE_SOURCE_FILE = 'interface.csv'
class GrantExecute class GrantExecute
TEMPLATE=<<-END TEMPLATE_FILE = 'templates/grant-execute.erb'
GRANT EXECUTE ON FUNCTION <%= GEOCODER_CLIENT_SCHEMA %>.<%= function_signature['function_name'] %>(<%= function_signature['argument_data_types'] %>) TO publicuser;
END
attr_reader :function_signature attr_reader :function_signature
def initialize(function_signature) def initialize(function_signature)
@function_signature = function_signature @function_signature = function_signature
@template = File.read(TEMPLATE_FILE)
end end
def render def render
ERB.new(TEMPLATE).result(binding) ERB.new(@template).result(binding)
end end
end end
+1
View File
@@ -0,0 +1 @@
GRANT EXECUTE ON FUNCTION <%= GEOCODER_CLIENT_SCHEMA %>.<%= function_signature['function_name'] %>(<%= function_signature['argument_data_types'] %>) TO publicuser;