Class: CdnTags::Configuration
- Inherits:
-
Object
- Object
- CdnTags::Configuration
- Defined in:
- lib/cdn_tags/configuration.rb
Instance Attribute Summary collapse
-
#add_to_precompile ⇒ Object
Returns the value of attribute add_to_precompile.
-
#cdn_environments ⇒ Object
Returns the value of attribute cdn_environments.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#raise_on_missing ⇒ Object
Returns the value of attribute raise_on_missing.
-
#scripts_urls ⇒ Object
Returns the value of attribute scripts_urls.
-
#stylesheets_urls ⇒ Object
Returns the value of attribute stylesheets_urls.
Instance Method Summary collapse
- #fix_cdn_environments_keys! ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #post_configure_hooks ⇒ Object
- #update_rails_precompile! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
8 9 10 11 12 13 14 15 |
# File 'lib/cdn_tags/configuration.rb', line 8 def initialize self.scripts_urls = {} self.stylesheets_urls = {} self.environment = Rails.env self.raise_on_missing = false self.add_to_precompile = true self.cdn_environments = [:production] end |
Instance Attribute Details
#add_to_precompile ⇒ Object
Returns the value of attribute add_to_precompile.
6 7 8 |
# File 'lib/cdn_tags/configuration.rb', line 6 def add_to_precompile @add_to_precompile end |
#cdn_environments ⇒ Object
Returns the value of attribute cdn_environments.
6 7 8 |
# File 'lib/cdn_tags/configuration.rb', line 6 def cdn_environments @cdn_environments end |
#environment ⇒ Object
Returns the value of attribute environment.
5 6 7 |
# File 'lib/cdn_tags/configuration.rb', line 5 def environment @environment end |
#raise_on_missing ⇒ Object
Returns the value of attribute raise_on_missing.
6 7 8 |
# File 'lib/cdn_tags/configuration.rb', line 6 def raise_on_missing @raise_on_missing end |
#scripts_urls ⇒ Object
Returns the value of attribute scripts_urls.
5 6 7 |
# File 'lib/cdn_tags/configuration.rb', line 5 def scripts_urls @scripts_urls end |
#stylesheets_urls ⇒ Object
Returns the value of attribute stylesheets_urls.
5 6 7 |
# File 'lib/cdn_tags/configuration.rb', line 5 def stylesheets_urls @stylesheets_urls end |
Instance Method Details
#fix_cdn_environments_keys! ⇒ Object
22 23 24 |
# File 'lib/cdn_tags/configuration.rb', line 22 def fix_cdn_environments_keys! self.cdn_environments.map! { |s| s.to_sym } end |
#post_configure_hooks ⇒ Object
17 18 19 20 |
# File 'lib/cdn_tags/configuration.rb', line 17 def post_configure_hooks self.update_rails_precompile! self.fix_cdn_environments_keys! end |
#update_rails_precompile! ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/cdn_tags/configuration.rb', line 26 def update_rails_precompile! return unless self.add_to_precompile scripts_precompile = self.scripts_urls.keys.map { |s| should_append_extension(s) ? "#{s}.js" : s } stylesheets_precompile = self.stylesheets_urls.keys.map { |s| should_append_extension(s) ? "#{s}.css" : s } added_precompile = scripts_precompile + stylesheets_precompile Rails.application.config.assets.precompile += added_precompile end |