Module: Trackman::Assets::AssetFactory
- Included in:
- Asset, RemoteAssetFactory
- Defined in:
- lib/trackman/assets/asset_factory.rb
Instance Method Summary collapse
- #add_content_behavior(instance) ⇒ Object
- #asset_pipeline_enabled? ⇒ Boolean
- #create(attributes = {}) ⇒ Object
- #rails_defined? ⇒ Boolean
- #retrieve_parent(path) ⇒ Object
Instance Method Details
#add_content_behavior(instance) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/trackman/assets/asset_factory.rb', line 21 def add_content_behavior instance if asset_pipeline_enabled? instance.extend Trackman::Path::Rails32Resolver, BundledAsset return instance elsif rails_defined? #fallback to rails without asset pipeline instance.extend Trackman::Path::Resolver end instance.extend Trackman::Components::Hashable instance end |
#asset_pipeline_enabled? ⇒ Boolean
37 38 39 40 41 42 43 |
# File 'lib/trackman/assets/asset_factory.rb', line 37 def asset_pipeline_enabled? rails_defined? && Rails.respond_to?(:application) && Rails.application.config.assets.enabled && Rails.application.respond_to?(:assets) && Rails.application.assets end |
#create(attributes = {}) ⇒ Object
4 5 6 7 8 |
# File 'lib/trackman/assets/asset_factory.rb', line 4 def create attributes = {} path = attributes[:path] instance = retrieve_parent(path).new attributes add_content_behavior instance end |
#rails_defined? ⇒ Boolean
33 34 35 |
# File 'lib/trackman/assets/asset_factory.rb', line 33 def rails_defined? Object.const_defined?(:Rails) end |