Sha256: 4510d6668744d95151b0568be7abb6a71ea6e8923d537e1f9542d36f57fe0283

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

module KirguduBase
	class DynamicPages::Element

			include ActiveModel::Validations

			include ::KirguduBase::Models::MergeableElements::InstanceMethods
			extend ::KirguduBase::Models::MergeableElements::ClassMethods

			include ::KirguduBase::Models::FixableElements::InstanceMethods
			extend ::KirguduBase::Models::FixableElements::ClassMethods


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


			attr_accessor :parent_entry

			def fix_parent_entry(parent_entry)
				if parent_entry
					unless parent_entry.is_a?(::KirguduBase::DynamicPages::Element)
						raise "Parent Entry must be a derivative of class ::KirguduBase::Pages::Element"
					end
					self.parent_entry = parent_entry
				end
			end

			def to_external_hash(options = {})
				options ||= {}
				options
			end

			def kontroller_klass
				self.parent_entry.kontroller_klass if self.parent_entry && self.parent_entry.respond_to?(:kontroller_klass)
			end

			def as_json(options = {})
				super((options || {}).merge({
					                            :except => [:parent_entry, :validation_context, :errors]
				                            }))
			end

			protected

		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/element.rb
kirgudu_base-0.0.23 app/models/kirgudu_base/dynamic_pages/element.rb
kirgudu_base-0.0.22 app/models/kirgudu_base/dynamic_pages/element.rb