Module: Pagy::Configurable
- Included in:
- Pagy
- Defined in:
- lib/pagy/deprecated.rb,
lib/pagy/modules/abilities/configurable.rb
Overview
Configuration methods
Instance Method Summary collapse
-
#dev_tools(wand_scale: 1) ⇒ Object
Generate the script and style tags to help development.
- #options ⇒ Object
-
#sync(resource, destination, *targets) ⇒ Object
Sync the pagy resource targets.
- #sync_javascript ⇒ Object
-
#translate_with_the_slower_i18n_gem! ⇒ Object
Setup pagy for using the i18n gem.
Instance Method Details
#dev_tools(wand_scale: 1) ⇒ Object
Generate the script and style tags to help development
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/pagy/modules/abilities/configurable.rb', line 16 def dev_tools(wand_scale: 1) <<~HTML <script id="pagy-ai-widget"> #{ROOT.join('javascripts/ai_widget.js').read} </script> <script id="pagy-wand" data-scale="#{wand_scale}"> #{ROOT.join('javascripts/wand.js').read} </script> <style id="pagy-wand-default"> #{ROOT.join('stylesheets/pagy.css').read} </style> HTML end |
#options ⇒ Object
73 74 75 76 77 |
# File 'lib/pagy/deprecated.rb', line 73 def OPTIONS.tap do warn "[PAGY] 'Pagy.options' is deprecated: use 'Pagy::OPTIONS directly'" end end |
#sync(resource, destination, *targets) ⇒ Object
Sync the pagy resource targets.
7 8 9 10 11 12 13 |
# File 'lib/pagy/modules/abilities/configurable.rb', line 7 def sync(resource, destination, *targets) files = ROOT.join("#{resource}s").glob("{#{targets.join(',')}}") unknownn = targets - files.map { |f| f.basename.to_s } raise InternalError, "Resource not known: #{unknownn.join(', ')}" if unknownn.any? FileUtils.cp(files, destination) end |
#sync_javascript ⇒ Object
79 80 81 82 |
# File 'lib/pagy/deprecated.rb', line 79 def sync_javascript(...) warn "[PAGY] 'Pagy.sync_javascript(...)' is deprecated: use 'Pagy.sync(:javascript, ...)' instead." sync(:javascript, ...) end |
#translate_with_the_slower_i18n_gem! ⇒ Object
Setup pagy for using the i18n gem
31 32 33 34 35 |
# File 'lib/pagy/modules/abilities/configurable.rb', line 31 def translate_with_the_slower_i18n_gem! send(:remove_const, :I18n) send(:const_set, :I18n, ::I18n) ::I18n.load_path += Dir[ROOT.join('locales/*.yml')] end |