class Bh::Classes::Modal
Public Class Methods
new(app = nil, *args, &block)
click to toggle source
Differently from other classes, Modal
works with no content or block, given that the options is passed, in which case it functions as the content.
Calls superclass method
Bh::Classes::Base::new
# File lib/bh/classes/modal.rb, line 9 def initialize(app = nil, *args, &block) if args.first.is_a?(Hash) && !block_given? args.unshift args.first.delete(:body) end super end
Private Class Methods
dialog_sizes()
click to toggle source
@return [Hash<Symbol, String>] the classes that Bootstrap requires to
append to the modal dialog for each possible size.
# File lib/bh/classes/modal.rb, line 50 def self.dialog_sizes HashWithIndifferentAccess.new.tap do |klass| klass[:large] = :'modal-lg' klass[:lg] = :'modal-lg' klass[:sm] = :'modal-sm' klass[:small] = :'modal-sm' end end
Public Instance Methods
caption()
click to toggle source
@return [#to_s] the caption for the modal button.
# File lib/bh/classes/modal.rb, line 33 def caption @options.fetch(:button, {}).fetch :caption, title end
dialog_size_class()
click to toggle source
@return [#to_s] the size-related class to assign to the modal dialog.
# File lib/bh/classes/modal.rb, line 28 def dialog_size_class Modal.dialog_sizes[@options[:size]] end
id()
click to toggle source
# File lib/bh/classes/modal.rb, line 42 def id @options.fetch :id, "modal-#{rand 10**10}" end
title()
click to toggle source
@return [#to_s] the title to display on top of the modal dialog.
# File lib/bh/classes/modal.rb, line 38 def title @options.fetch :title, 'Modal' end
Private Instance Methods
extract_content_from(*args, &block)
click to toggle source
Calls superclass method
Bh::Classes::Base#extract_content_from
# File lib/bh/classes/modal.rb, line 59 def extract_content_from(*args, &block) if block_given? super else @app.content_tag :div, super, class: 'modal-body' end end