Sha256: dbb80111c88347822e5d1ef6475c5d0be7d5eece59a2fe6468e8d961abba4b44

Contents?: true

Size: 1.32 KB

Versions: 18

Compression:

Stored size: 1.32 KB

Contents

module KirguduBase
	module DynamicPages
		class PageElement < ::KirguduBase::DynamicPages::Element

			mergeable_attributes :name, :id, :html_options, :enabled, :visible, :use_i18n

			validates_inclusion_of :enabled, in: [:true, :false], allow_nil: true
			validates_inclusion_of :visible, in: [:true, :false], allow_nil: true
			validates_inclusion_of :use_i18n, in: [:true, :false], allow_nil: true


			def initialize(options = {})
				self.name = nil
				self.id = nil
				self.html_options= {}
				self.enabled = :true
				self.visible = :true
				self.use_i18n = :true


				super(options)

			end

			attr_accessor :name
			attr_accessor :id
			attr_accessor :html_options
			attr_accessor :visible
			attr_accessor :enabled
			attr_accessor :use_i18n



			def to_external_hash(options = {})
				options ||= {}
				options.merge!({
					               name: self.name,
					               id: self.id,
					               html_options: self.html_options,
				                   visible: self.visible == :true,
				                   enabled: self.enabled == :true
				               })
				super(options)
			end

			def i18n_data_as_string(method)
				if method == nil
					raise "I18N for Page Element: Method supplied is nil"
				end
				data = self.send(method)
				self.use_i18n == :true ? ::I18n.t(data) : data
			end

		end
	end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
kirgudu_base-0.0.21 app/models/kirgudu_base/dynamic_pages/page_element.rb
kirgudu_base-0.0.19 app/models/kirgudu_base/dynamic_pages/page_element.rb
kirgudu_base-0.0.18 app/models/kirgudu_base/dynamic_pages/page_element.rb
kirgudu_base-0.0.17 app/models/kirgudu_base/dynamic_pages/page_element.rb
kirgudu_base-0.0.16 app/models/kirgudu_base/dynamic_pages/page_element.rb
kirgudu_base-0.0.15 app/models/kirgudu_base/dynamic_pages/page_element.rb
kirgudu_base-0.0.14 app/models/kirgudu_base/dynamic_pages/page_element.rb
kirgudu_base-0.0.13 app/models/kirgudu_base/dynamic_pages/page_element.rb
kirgudu_base-0.0.12 app/models/kirgudu_base/dynamic_pages/page_element.rb
kirgudu_base-0.0.11 app/models/kirgudu_base/dynamic_pages/page_element.rb
kirgudu_base-0.0.10 app/models/kirgudu_base/dynamic_pages/page_element.rb
kirgudu_base-0.0.9 app/models/kirgudu_base/dynamic_pages/page_element.rb
kirgudu_base-0.0.8 app/models/kirgudu_base/dynamic_pages/page_element.rb
kirgudu_base-0.0.7 app/models/kirgudu_base/dynamic_pages/page_element.rb
kirgudu_base-0.0.6 app/models/kirgudu_base/dynamic_pages/page_element.rb
kirgudu_base-0.0.5 app/models/kirgudu_base/dynamic_pages/page_element.rb
kirgudu_base-0.0.4 app/models/kirgudu_base/dynamic_pages/page_element.rb
kirgudu_base-0.0.3 app/models/kirgudu_base/dynamic_pages/page_element.rb