Class: Olivander::ApplicationContext
- Inherits:
-
Object
- Object
- Olivander::ApplicationContext
- Defined in:
- lib/olivander/application_context.rb
Overview
DTO to represent the overall application context
Defined Under Namespace
Classes: Company, LoginLogo, Logo
Constant Summary collapse
- DEFAULT_APPLICATION_NAME =
'Application Name'- DEFAULT_SIGN_OUT_PATH =
'/users/sign_out'- DEFAULT_HEADER_CLASSES =
''- DEFAULT_LOGO_URL =
'/images/olivander_logo.png'- DEFAULT_LOGO_ALT =
'Logo Image'- DEFAULT_LOGIN_LOGO_URL =
'/images/olivander_login_logo.png'- DEFAULT_LOGIN_LOGO_ALT =
'Login Logo Image'- DEFAULT_COMPANY_URL =
'/'- DEFAULT_COMPANY_ALT =
'Company Name'- DEFAULT_LAYOUT_CLASS =
'hold-transition sidebar-mini layout-fixed'- DEFAULT_NAV_CLASS =
'navbar-expand navbar-white navbar-light'
Instance Attribute Summary collapse
-
#back_to_top ⇒ Object
Returns the value of attribute back_to_top.
-
#company ⇒ Object
Returns the value of attribute company.
-
#layout_class ⇒ Object
Returns the value of attribute layout_class.
-
#layout_container ⇒ Object
Returns the value of attribute layout_container.
-
#login_logo ⇒ Object
Returns the value of attribute login_logo.
-
#logo ⇒ Object
Returns the value of attribute logo.
-
#menu_items ⇒ Object
Returns the value of attribute menu_items.
-
#name ⇒ Object
Returns the value of attribute name.
-
#nav_class ⇒ Object
Returns the value of attribute nav_class.
-
#nav_container ⇒ Object
Returns the value of attribute nav_container.
-
#route_builder ⇒ Object
Returns the value of attribute route_builder.
-
#sidebar ⇒ Object
Returns the value of attribute sidebar.
-
#sidebar_background_class ⇒ Object
Returns the value of attribute sidebar_background_class.
-
#sidebar_class ⇒ Object
Returns the value of attribute sidebar_class.
-
#sign_out_path ⇒ Object
Returns the value of attribute sign_out_path.
Instance Method Summary collapse
- #back_to_top? ⇒ Boolean
-
#initialize(**kwargs) ⇒ ApplicationContext
constructor
A new instance of ApplicationContext.
- #layout_container? ⇒ Boolean
- #nav_container? ⇒ Boolean
- #sidebar? ⇒ Boolean
- #visible_modules ⇒ Object
- #visible_modules_for(menu_item) ⇒ Object
Constructor Details
#initialize(**kwargs) ⇒ ApplicationContext
Returns a new instance of ApplicationContext.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/olivander/application_context.rb', line 24 def initialize(**kwargs) self.name = kwargs[:name] || ENV['OLIVANDER_APP_NAME'] || DEFAULT_APPLICATION_NAME self.logo = kwargs[:logo] || Logo.new(url: kwargs[:logo_url], alt: kwargs[:logo_alt]) self.login_logo = kwargs[:login_logo] || LoginLogo.new(url: kwargs[:login_logo_url], alt: kwargs[:login_logo_alt]) self.company = kwargs[:company] || Company.new(name: kwargs[:company_name], url: kwargs[:company_url]) self.sign_out_path = kwargs[:sign_out_path] || DEFAULT_SIGN_OUT_PATH self. = kwargs[:menu_items] || [] self.nav_container = kwargs[:nav_container] || 'false' == 'true' self.nav_class = kwargs[:nav_class] || DEFAULT_NAV_CLASS self.layout_container = kwargs[:layout_container] || 'false' == 'true' self.layout_class = kwargs[:layout_class] || DEFAULT_LAYOUT_CLASS self. = (kwargs[:sidebar] || true) self.back_to_top = (kwargs[:back_to_top] || true) begin self.route_builder = RouteBuilder.new rescue NameError self.route_builder = OpenStruct.new(resources: {}) end end |
Instance Attribute Details
#back_to_top ⇒ Object
Returns the value of attribute back_to_top.
7 8 9 |
# File 'lib/olivander/application_context.rb', line 7 def back_to_top @back_to_top end |
#company ⇒ Object
Returns the value of attribute company.
7 8 9 |
# File 'lib/olivander/application_context.rb', line 7 def company @company end |
#layout_class ⇒ Object
Returns the value of attribute layout_class.
7 8 9 |
# File 'lib/olivander/application_context.rb', line 7 def layout_class @layout_class end |
#layout_container ⇒ Object
Returns the value of attribute layout_container.
7 8 9 |
# File 'lib/olivander/application_context.rb', line 7 def layout_container @layout_container end |
#login_logo ⇒ Object
Returns the value of attribute login_logo.
7 8 9 |
# File 'lib/olivander/application_context.rb', line 7 def login_logo @login_logo end |
#logo ⇒ Object
Returns the value of attribute logo.
7 8 9 |
# File 'lib/olivander/application_context.rb', line 7 def logo @logo end |
#menu_items ⇒ Object
Returns the value of attribute menu_items.
7 8 9 |
# File 'lib/olivander/application_context.rb', line 7 def @menu_items end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/olivander/application_context.rb', line 7 def name @name end |
#nav_class ⇒ Object
Returns the value of attribute nav_class.
7 8 9 |
# File 'lib/olivander/application_context.rb', line 7 def nav_class @nav_class end |
#nav_container ⇒ Object
Returns the value of attribute nav_container.
7 8 9 |
# File 'lib/olivander/application_context.rb', line 7 def nav_container @nav_container end |
#route_builder ⇒ Object
Returns the value of attribute route_builder.
7 8 9 |
# File 'lib/olivander/application_context.rb', line 7 def route_builder @route_builder end |
#sidebar ⇒ Object
Returns the value of attribute sidebar.
7 8 9 |
# File 'lib/olivander/application_context.rb', line 7 def @sidebar end |
#sidebar_background_class ⇒ Object
Returns the value of attribute sidebar_background_class.
7 8 9 |
# File 'lib/olivander/application_context.rb', line 7 def @sidebar_background_class end |
#sidebar_class ⇒ Object
Returns the value of attribute sidebar_class.
7 8 9 |
# File 'lib/olivander/application_context.rb', line 7 def @sidebar_class end |
#sign_out_path ⇒ Object
Returns the value of attribute sign_out_path.
7 8 9 |
# File 'lib/olivander/application_context.rb', line 7 def sign_out_path @sign_out_path end |
Instance Method Details
#back_to_top? ⇒ Boolean
44 45 46 |
# File 'lib/olivander/application_context.rb', line 44 def back_to_top? back_to_top.to_s == 'true' end |
#layout_container? ⇒ Boolean
52 53 54 |
# File 'lib/olivander/application_context.rb', line 52 def layout_container? layout_container.to_s == 'true' end |
#nav_container? ⇒ Boolean
48 49 50 |
# File 'lib/olivander/application_context.rb', line 48 def nav_container? nav_container.to_s == 'true' end |
#sidebar? ⇒ Boolean
56 57 58 |
# File 'lib/olivander/application_context.rb', line 56 def .to_s == 'true' end |
#visible_modules ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/olivander/application_context.rb', line 60 def visible_modules [].tap do |arr| .each do || arr << visible_modules_for() end end.flatten end |
#visible_modules_for(menu_item) ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'lib/olivander/application_context.rb', line 68 def visible_modules_for() [].tap do |arr| arr << if .module? && .visible ..each do |sub| arr << visible_modules_for(sub) end end end |