Sha256: eebd6cfbfa388573f0f4cb6a26a4a3f41863c0b17605b99a6c30e269dab983df
Contents?: true
Size: 1.23 KB
Versions: 23
Compression:
Stored size: 1.23 KB
Contents
require "horse_power/engine" module HorsePower def self.params_list(attributes) params = [] attributes.each do |pair| elem = pair.split(/:/)[0] field = ":#{elem}" params << field end return params.join(",") end def self.get_column(pair) return pair.split(/:/)[0] end def self.get_type(pair) return pair.split(/:/)[1] end def self.get_singular(resource) return resource.underscore.singularize end def self.get_plural(resource) return resource.underscore.pluralize end def self.get_camel(resource) return resource.camelize.singularize end def self.get_camel_plural(resource) return self.get_camel(resource).pluralize end def self.default_values(field1) field = field1.downcase if field == "integer" return 1 end if field == "boolean" return true end if field == "string" return "\"Default String\"" end if field == "text" return "\"Default Text\"" end if field == "float" return 3.14 end if field == "decimal" return 3.14159 end if field == "date" return "\"#{Date.new}\"" end if field == "time" return "\"#{Time.new}\"" end if field == "datetime" return "\"#{DateTime.new}\"" end #If there are any values that I missed return nil end end
Version data entries
23 entries across 23 versions & 1 rubygems