class Gris::Generators::ApiGenerator
Public Instance Methods
api()
click to toggle source
# File lib/gris/generators/api_generator.rb, line 48 def api self.class.source_root "#{File.dirname(__FILE__)}/templates/api" say 'Generating api...' directory '.', output_directory say 'API files created!', :green end
append_endpoint_links_to_root_presenter()
click to toggle source
# File lib/gris/generators/api_generator.rb, line 39 def append_endpoint_links_to_root_presenter say 'Appending links to RootPresenter.' insert_into_file path_to_root_presenter, after: "# Additional endpoint links\n" do text = "\n" text << " resource_links :#{name_underscore}\n" text end end
append_endpoint_to_application_endpoint()
click to toggle source
# File lib/gris/generators/api_generator.rb, line 31 def append_endpoint_to_application_endpoint say 'Mounting new endpoint on ApplicationEndpoint.' insert_into_file path_to_application_endpoint, after: "# Additional mounted endpoints\n" do text = " mount #{name.classify.pluralize}Endpoint\n" text end end
name_tableize()
click to toggle source
# File lib/gris/generators/api_generator.rb, line 15 def name_tableize name.tableize end
name_underscore()
click to toggle source
# File lib/gris/generators/api_generator.rb, line 11 def name_underscore name.underscore end
output_directory()
click to toggle source
# File lib/gris/generators/api_generator.rb, line 19 def output_directory '.' end
path_to_application_endpoint()
click to toggle source
# File lib/gris/generators/api_generator.rb, line 23 def path_to_application_endpoint "#{output_directory}/app/endpoints/application_endpoint.rb" end
path_to_root_presenter()
click to toggle source
# File lib/gris/generators/api_generator.rb, line 27 def path_to_root_presenter "#{output_directory}/app/presenters/root_presenter.rb" end