Sha256: 24d33fd49e276736b4ce8a23ebf423d29eab06d6543e3ea2901e49ca5d823630

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 KB

Contents

class KirguduBase::DynamicPages::Form

	SUPPORTED_HTTP_METHODS = [:get, :post, :put, :delete]

	def initialize(options = {})
		self.name = nil
		self.url = nil
		self.http_method = :get
		self.allow_client_validations = false
		self.is_ajax = false
		self.draw_form_element = true
		@html_options= {}
		@properties = {}

		if options
			options.symbolize_keys!
			options.each_pair do |key, value|
				self.send("#{key}=", value)
			end
		end

	end


	def name
		@name
	end

	def name= value
		@name = value
	end

	def url
		@url
	end

	def url= value
		@url = value
	end


	def http_method
		@http_method
	end
	def http_method= value
		raise "Method ':#{value}' is not supported at the Moment. Supported Methods are #{SUPPORTED_HTTP_METHODS.map{ |i| ":#{i}" }.join(", ")}" unless SUPPORTED_HTTP_METHODS.include?(value)
		@http_method = value
	end




	def draw_form_element
		@draw_form_element
	end

	def draw_form_element= value
		@draw_form_element = value ? true : false
	end

	def allow_client_validations
		@allow_client_validations
	end

	def allow_client_validations= value
		@allow_client_validations = value ? true : false
	end

	def is_ajax
		@is_ajax
	end

	def is_ajax= value
		@is_ajax = value ? true : false
	end

	def html_options
		@html_options
	end

	def html_option(value = {})
		@html_options.merge!(value)
	end



	def properties
		@properties.each_value.map{ |v| v }
	end

	def property(property)
		#raise column.name
		raise "Cannot create empty Property" unless property
		raise "Duplicate Property with name: #{property.name}" if @properties[property.name]
		@properties[property.name] = property
	end


end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kirgudu_base-0.0.1 app/models/kirgudu_base/dynamic_pages/form.rb