class Rails::ApiblueprintGenerator
Public Instance Methods
create_apib_file()
click to toggle source
# File lib/generators/rails/apiblueprint/apiblueprint_generator.rb, line 39 def create_apib_file template "apiblueprint.erb", "#{options["apidoc-dir"]}/#{file_name}.apib" if options["generate"] != "none" then invoke(options["generate"], [file_name, @args]) end end
set_attribute()
click to toggle source
# File lib/generators/rails/apiblueprint/apiblueprint_generator.rb, line 17 def set_attribute @attrs = Array.new() @args = Array.new() attributes.map do |val| @attrs.push( { name: val.name, type: val.type, init: val.default } ) end @attrs.map do |attr| @args.push(attr[:name].to_s + ":" + attr[:type].to_s) case attr[:type].to_s when "integer", "primary_key", "decimal", "float" then attr[:type] = "number" when "boolean" then attr[:type] = "boolean" when "references" then attr[:name] = attr[:name] + "_id" attr[:type] = "number, required" else attr[:type] = "string" end end end