Class: KirguduBase::DynamicPages::PageElement

Inherits:
Element
  • Object
show all
Defined in:
app/models/kirgudu_base/dynamic_pages/page_element.rb

Instance Attribute Summary collapse

Attributes inherited from Element

#parent_entry

Instance Method Summary collapse

Methods inherited from Element

#as_json, #fix_parent_entry, #kontroller_klass

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::FixableElements::InstanceMethods

#fix_parent_entry

Methods included from Models::MergeableElements::InstanceMethods

#merge

Constructor Details

#initialize(options = {}) ⇒ PageElement

Returns a new instance of PageElement.



12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/models/kirgudu_base/dynamic_pages/page_element.rb', line 12

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

Instance Attribute Details

#enabledObject

Returns the value of attribute enabled.



29
30
31
# File 'app/models/kirgudu_base/dynamic_pages/page_element.rb', line 29

def enabled
  @enabled
end

#html_optionsObject

Returns the value of attribute html_options.



27
28
29
# File 'app/models/kirgudu_base/dynamic_pages/page_element.rb', line 27

def html_options
  @html_options
end

#idObject

Returns the value of attribute id.



26
27
28
# File 'app/models/kirgudu_base/dynamic_pages/page_element.rb', line 26

def id
  @id
end

#nameObject

Returns the value of attribute name.



25
26
27
# File 'app/models/kirgudu_base/dynamic_pages/page_element.rb', line 25

def name
  @name
end

#use_i18nObject

Returns the value of attribute use_i18n.



30
31
32
# File 'app/models/kirgudu_base/dynamic_pages/page_element.rb', line 30

def use_i18n
  @use_i18n
end

#visibleObject

Returns the value of attribute visible.



28
29
30
# File 'app/models/kirgudu_base/dynamic_pages/page_element.rb', line 28

def visible
  @visible
end

Instance Method Details

#i18n_data_as_string(method) ⇒ Object



46
47
48
49
50
51
52
# File 'app/models/kirgudu_base/dynamic_pages/page_element.rb', line 46

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

#to_external_hash(options = {}) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
# File 'app/models/kirgudu_base/dynamic_pages/page_element.rb', line 34

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