Class: Mxrb::Dsl::NavigationProfileBuilder
- Inherits:
-
Object
- Object
- Mxrb::Dsl::NavigationProfileBuilder
- Defined in:
- lib/mxrb/dsl/builder.rb
Instance Method Summary collapse
- #evaluate(path) ⇒ Object
- #evaluate_dir(dir) ⇒ Object
- #home_for(role, page: nil, microflow: nil) ⇒ Object
-
#initialize(name, **options) ⇒ NavigationProfileBuilder
constructor
A new instance of NavigationProfileBuilder.
- #item(caption, page: nil, microflow: nil, icon: nil, translations: {}, &block) ⇒ Object
- #title(locale, text) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(name, **options) ⇒ NavigationProfileBuilder
Returns a new instance of NavigationProfileBuilder.
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 |
# File 'lib/mxrb/dsl/builder.rb', line 466 def initialize(name, **) @name = name.to_s @home_page = optional_string(, :home_page) @home_microflow = optional_string(, :home_microflow) @sign_in_page = optional_string(, :sign_in_page) @menu = optional_string(, :menu) @offline = [:offline] == true @kind = optional_string(, :kind) @app_icon = optional_string(, :app_icon) @app_title = normalize_translations([:app_title]) @role_homes = .fetch(:role_homes, {}).to_h.transform_keys(&:to_s) .transform_values(&:to_s) @role_home_details = [] @items = [] end |
Instance Method Details
#evaluate(path) ⇒ Object
500 501 502 |
# File 'lib/mxrb/dsl/builder.rb', line 500 def evaluate(path) instance_eval(File.read(path), path, 1) end |
#evaluate_dir(dir) ⇒ Object
504 505 506 507 508 |
# File 'lib/mxrb/dsl/builder.rb', line 504 def evaluate_dir(dir) return unless File.directory?(dir) Dir[File.join(dir, '*.rb')].sort.each { |path| evaluate(path) } end |
#home_for(role, page: nil, microflow: nil) ⇒ Object
486 487 488 489 490 |
# File 'lib/mxrb/dsl/builder.rb', line 486 def home_for(role, page: nil, microflow: nil) @role_home_details << { role: role.to_s, page: page&.to_s, microflow: microflow&.to_s }.compact end |
#item(caption, page: nil, microflow: nil, icon: nil, translations: {}, &block) ⇒ Object
492 493 494 495 496 497 498 |
# File 'lib/mxrb/dsl/builder.rb', line 492 def item(caption, page: nil, microflow: nil, icon: nil, translations: {}, &block) builder = NavigationMenuItemBuilder.new( caption, page:, microflow:, icon:, translations: ) builder.instance_eval(&block) if block @items << builder.to_h end |
#title(locale, text) ⇒ Object
482 483 484 |
# File 'lib/mxrb/dsl/builder.rb', line 482 def title(locale, text) @app_title[locale.to_s] = text.to_s end |
#to_h ⇒ Object
510 511 512 513 514 515 516 517 |
# File 'lib/mxrb/dsl/builder.rb', line 510 def to_h { name: @name, home_page: @home_page, home_microflow: @home_microflow, sign_in_page: @sign_in_page, menu: @menu, role_homes: @role_homes, role_home_details: @role_home_details, offline: @offline, kind: @kind, app_title: @app_title, app_icon: @app_icon, items: @items } end |