class Apiotics::ModelGenerator
Public Instance Methods
run_generators()
click to toggle source
# File lib/generators/apiotics/model/model_generator.rb, line 8 def run_generators generate "apiotics:create_table", arguments if @c == nil generate "apiotics:create_model", "#{parent} #{name}" else generate "apiotics:create_model", thorify generate "apiotics:initializer", "true" end end
Private Instance Methods
arguments()
click to toggle source
# File lib/generators/apiotics/model/model_generator.rb, line 20 def arguments if attributes == nil return get_attributes else return parent.to_s + " " + name.to_s + " " + stringify end end
get_attributes()
click to toggle source
# File lib/generators/apiotics/model/model_generator.rb, line 36 def get_attributes @c = Apiotics.get_attributes(parent, name) if @c[:kind] == "script" generate "apiotics:script", "#{parent} #{name}" end string = String.new @c[:attributes].each do |k,v| if v[:type] == "enum" string = string + k.gsub(" ", "_").downcase + ":" + "integer" + " " else string = string + k.gsub(" ", "_").downcase + ":" + v[:type] + " " end end return parent.to_s + " " + name.to_s + " " + string end
stringify()
click to toggle source
# File lib/generators/apiotics/model/model_generator.rb, line 28 def stringify string = String.new attributes.each do |k,v| string = string + k + ":" + v + " " end string end
thorify()
click to toggle source
# File lib/generators/apiotics/model/model_generator.rb, line 52 def thorify string = String.new string = parent.to_s + " " + name.to_s + " " + "true" end