Class: KirguduBase::DynamicPages::Element

Inherits:
Object
  • Object
show all
Extended by:
Models::FixableElements::ClassMethods, Models::MergeableElements::ClassMethods
Includes:
ActiveModel::Validations, Models::FixableElements::InstanceMethods, Models::MergeableElements::InstanceMethods
Defined in:
app/models/kirgudu_base/dynamic_pages/element.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Models::MergeableElements::ClassMethods

get_mergeable_attributes, mergeable_attributes

Methods included from Models::FixableElements::ClassMethods

fixable_attributes, get_kb_fixable_attributes

Methods included from Models::MergeableElements::InstanceMethods

#merge

Constructor Details

#initialize(options = {}) ⇒ Element

Returns a new instance of Element.



14
15
16
17
18
19
20
21
# File 'app/models/kirgudu_base/dynamic_pages/element.rb', line 14

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

Instance Attribute Details

#parent_entryObject

Returns the value of attribute parent_entry.



24
25
26
# File 'app/models/kirgudu_base/dynamic_pages/element.rb', line 24

def parent_entry
  @parent_entry
end

Instance Method Details

#as_json(options = {}) ⇒ Object



44
45
46
47
48
# File 'app/models/kirgudu_base/dynamic_pages/element.rb', line 44

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

#fix_parent_entry(parent_entry) ⇒ Object



26
27
28
29
30
31
32
33
# File 'app/models/kirgudu_base/dynamic_pages/element.rb', line 26

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

#kontroller_klassObject



40
41
42
# File 'app/models/kirgudu_base/dynamic_pages/element.rb', line 40

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

#to_external_hash(options = {}) ⇒ Object



35
36
37
38
# File 'app/models/kirgudu_base/dynamic_pages/element.rb', line 35

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