Class: Olivander::ApplicationContext
- Inherits:
-
Object
- Object
- Olivander::ApplicationContext
- Defined in:
- lib/olivander/application_context.rb
Defined Under Namespace
Classes: Company, LoginLogo, Logo
Instance Attribute Summary collapse
-
#company ⇒ Object
Returns the value of attribute company.
-
#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.
-
#route_builder ⇒ Object
Returns the value of attribute route_builder.
-
#sidebar_background_class ⇒ Object
Returns the value of attribute sidebar_background_class.
-
#sign_out_path ⇒ Object
Returns the value of attribute sign_out_path.
Instance Method Summary collapse
-
#initialize(**kwargs) ⇒ ApplicationContext
constructor
A new instance of ApplicationContext.
- #visible_modules ⇒ Object
- #visible_modules_for(menu_item) ⇒ Object
Constructor Details
#initialize(**kwargs) ⇒ ApplicationContext
Returns a new instance of ApplicationContext.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/olivander/application_context.rb', line 5 def initialize(**kwargs) self.name = kwargs[:name] || ENV['OLIVANDER_APP_NAME'] || '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] || '/sign_out' self. = kwargs[:menu_items] || [] begin self.route_builder = RouteBuilder.new rescue NameError self.route_builder = OpenStruct.new(resources: {}) end end |
Instance Attribute Details
#company ⇒ Object
Returns the value of attribute company.
3 4 5 |
# File 'lib/olivander/application_context.rb', line 3 def company @company end |
#login_logo ⇒ Object
Returns the value of attribute login_logo.
3 4 5 |
# File 'lib/olivander/application_context.rb', line 3 def login_logo @login_logo end |
#logo ⇒ Object
Returns the value of attribute logo.
3 4 5 |
# File 'lib/olivander/application_context.rb', line 3 def logo @logo end |
#menu_items ⇒ Object
Returns the value of attribute menu_items.
3 4 5 |
# File 'lib/olivander/application_context.rb', line 3 def @menu_items end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/olivander/application_context.rb', line 3 def name @name end |
#route_builder ⇒ Object
Returns the value of attribute route_builder.
3 4 5 |
# File 'lib/olivander/application_context.rb', line 3 def route_builder @route_builder end |
#sidebar_background_class ⇒ Object
Returns the value of attribute sidebar_background_class.
3 4 5 |
# File 'lib/olivander/application_context.rb', line 3 def @sidebar_background_class end |
#sign_out_path ⇒ Object
Returns the value of attribute sign_out_path.
3 4 5 |
# File 'lib/olivander/application_context.rb', line 3 def sign_out_path @sign_out_path end |
Instance Method Details
#visible_modules ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/olivander/application_context.rb', line 19 def visible_modules [].tap do |arr| .each do || arr << visible_modules_for() end end.flatten end |
#visible_modules_for(menu_item) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/olivander/application_context.rb', line 27 def visible_modules_for() [].tap do |arr| arr << if .module? && .visible ..each do |sub| arr << visible_modules_for(sub) end end end |