Class: Mxrb::Model::Navigation

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_documentObject (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

Returns:

  • (Boolean)


30
# File 'lib/mxrb/model/navigation.rb', line 30

def empty? = @raw_document.empty?

#profilesObject



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_hObject



31
# File 'lib/mxrb/model/navigation.rb', line 31

def to_h = { profiles: profiles.map(&:to_h) }