Sha256: a489814269ada8b2ab5b32bd3fdbce7878c8ddcf018a98bd4e5fe1751e3161e8

Contents?: true

Size: 995 Bytes

Versions: 3

Compression:

Stored size: 995 Bytes

Contents

module KirguduBase
	class DynamicPages::FormPropertyBuilder < ::KirguduBase::DynamicPages::PropertyBuilder


		def initialize(name, &block)
			self.builder_options.merge!(
				{
					input_type: :text_edit,
					max_length: 0,
					read_only: :false,
					events: nil
				}
			)
			super(name, &block)
		end

		def events(&block)
			elements = ::KirguduBase::DynamicPages::PropertyEventsBlockBuilder.new(&block).to_elements

			elements.each do |element|
				self.builder_options[:events] = [] unless self.builder_options[:events]
				self.builder_options[:events] << element
			end
		end


		def input_type(value)
			self.builder_options[:input_type] = value
		end

		def max_length(value)
			self.builder_options[:max_length] = value
		end

		def read_only(value)
			self.builder_options[:read_only] = value
		end


		def to_element
			element =::KirguduBase::DynamicPages::FormProperty.new
			self.build_element(element)
			self.validate_generated_element(element)
			element
		end
	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kirgudu_base-0.0.25 app/models/kirgudu_base/dynamic_pages/form_property_builder.rb
kirgudu_base-0.0.23 app/models/kirgudu_base/dynamic_pages/form_property_builder.rb
kirgudu_base-0.0.22 app/models/kirgudu_base/dynamic_pages/form_property_builder.rb