Class: KirguduBase::DynamicPages::MenuItem
- Inherits:
-
PageElement
- Object
- Element
- PageElement
- KirguduBase::DynamicPages::MenuItem
- Defined in:
- app/models/kirgudu_base/dynamic_pages/menu_item.rb
Instance Attribute Summary collapse
-
#controller_link ⇒ Object
Returns the value of attribute controller_link.
-
#items ⇒ Object
Returns the value of attribute items.
-
#label ⇒ Object
Returns the value of attribute label.
-
#link ⇒ Object
Returns the value of attribute link.
-
#target ⇒ Object
Returns the value of attribute target.
Attributes inherited from PageElement
#enabled, #html_options, #id, #name, #use_i18n, #visible
Attributes inherited from Element
Instance Method Summary collapse
- #build_url(controller, prms) ⇒ Object
-
#initialize(options = {}) ⇒ MenuItem
constructor
A new instance of MenuItem.
- #to_external_hash(options = {}) ⇒ Object
Methods inherited from PageElement
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
Methods included from Models::MergeableElements::InstanceMethods
Constructor Details
#initialize(options = {}) ⇒ MenuItem
Returns a new instance of MenuItem.
14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/kirgudu_base/dynamic_pages/menu_item.rb', line 14 def initialize( = {}) self.label = nil self.link = nil self.target = :same self.controller_link = nil self.items = nil super() end |
Instance Attribute Details
#controller_link ⇒ Object
Returns the value of attribute controller_link.
29 30 31 |
# File 'app/models/kirgudu_base/dynamic_pages/menu_item.rb', line 29 def controller_link @controller_link end |
#items ⇒ Object
Returns the value of attribute items.
30 31 32 |
# File 'app/models/kirgudu_base/dynamic_pages/menu_item.rb', line 30 def items @items end |
#label ⇒ Object
Returns the value of attribute label.
26 27 28 |
# File 'app/models/kirgudu_base/dynamic_pages/menu_item.rb', line 26 def label @label end |
#link ⇒ Object
Returns the value of attribute link.
27 28 29 |
# File 'app/models/kirgudu_base/dynamic_pages/menu_item.rb', line 27 def link @link end |
#target ⇒ Object
Returns the value of attribute target.
28 29 30 |
# File 'app/models/kirgudu_base/dynamic_pages/menu_item.rb', line 28 def target @target end |
Instance Method Details
#build_url(controller, prms) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/models/kirgudu_base/dynamic_pages/menu_item.rb', line 46 def build_url(controller, prms) if self.link self.link else link_ids = {} if self.controller_link.id link_ids[self.controller_link.id.to] = prms[self.controller_link.id.from] elsif self.controller_link.ids self.controller_link.ids.each do |id| link_ids[id.to] = prms[id.from] end else prms.each_pair do |key, value| link_ids[key] = value end end kontroller_klass = nil if self.controller_link.controller.is_a?(String) kontroller_klass = eval(self.controller_link.controller) else kontroller_klass = self.controller_link.controller end kontroller_klass.to_url_for(self.controller_link.action, link_ids) end end |
#to_external_hash(options = {}) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/models/kirgudu_base/dynamic_pages/menu_item.rb', line 33 def to_external_hash( = {}) ||= {} .merge!({ #url: self.url, #data_format: self.data_format, #http_method: self.http_method, #label_property: self.label_property, #value_property: self.value_property }) super() end |