Class: Mxrb::Model::Navigation
- Inherits:
-
Object
- Object
- Mxrb::Model::Navigation
- Defined in:
- lib/mxrb/model/navigation.rb
Overview
Typed reader for modern and legacy native Mendix navigation documents.
Constant Summary collapse
- LEGACY_PROFILES =
{ 'DesktopProfile' => 'Desktop', 'TabletProfile' => 'Tablet', 'PhoneProfile' => 'Phone', 'OfflinePhoneProfile' => 'OfflinePhone', 'HybridPhoneProfile6' => 'HybridPhone', 'HybridTabletProfile6' => 'HybridTablet' }.freeze
Instance Attribute Summary collapse
-
#raw_document ⇒ Object
readonly
Returns the value of attribute raw_document.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(raw_document) ⇒ Navigation
constructor
A new instance of Navigation.
- #profiles ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(raw_document) ⇒ Navigation
Returns a new instance of Navigation.
18 19 20 |
# File 'lib/mxrb/model/navigation.rb', line 18 def initialize(raw_document) @raw_document = raw_document || {} end |
Instance Attribute Details
#raw_document ⇒ Object (readonly)
Returns the value of attribute raw_document.
16 17 18 |
# File 'lib/mxrb/model/navigation.rb', line 16 def raw_document @raw_document end |
Instance Method Details
#empty? ⇒ Boolean
30 |
# File 'lib/mxrb/model/navigation.rb', line 30 def empty? = @raw_document.empty? |
#profiles ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/mxrb/model/navigation.rb', line 22 def profiles @profiles ||= begin modern = items(@raw_document['Profiles']) documents = modern.empty? ? legacy_profile_documents : modern documents.map { NavigationProfile.new(_1) }.freeze end end |
#to_h ⇒ Object
31 |
# File 'lib/mxrb/model/navigation.rb', line 31 def to_h = { profiles: profiles.map(&:to_h) } |