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

Version Path
horse_power-1.0.0 lib/horse_power.rb
horse_power-0.9.0 lib/horse_power.rb
horse_power-0.8.5 lib/horse_power.rb
horse_power-0.8.3 lib/horse_power.rb
horse_power-0.8.2 lib/horse_power.rb
horse_power-0.8.1 lib/horse_power.rb
horse_power-0.8.0 lib/horse_power.rb
horse_power-0.7.1 lib/horse_power.rb
horse_power-0.7.0 lib/horse_power.rb
horse_power-0.6.5 lib/horse_power.rb
horse_power-0.6.0 lib/horse_power.rb
horse_power-0.5.0 lib/horse_power.rb
horse_power-0.4.1 lib/horse_power.rb
horse_power-0.4.0 lib/horse_power.rb
horse_power-0.3.3 lib/horse_power.rb
horse_power-0.3.2 lib/horse_power.rb
horse_power-0.2.1 lib/horse_power.rb
horse_power-0.2.0 lib/horse_power.rb
horse_power-0.1.6 lib/horse_power.rb
horse_power-0.1.5 lib/horse_power.rb