Class: ActionView::Helpers::AssetTagHelper::AssetTag
- Inherits:
-
Object
- Object
- ActionView::Helpers::AssetTagHelper::AssetTag
show all
- Extended by:
- ActiveSupport::Memoizable
- Defined in:
- lib/action_view/helpers/asset_tag_helper.rb
Constant Summary
collapse
- Cache =
{}
- CacheGuard =
Mutex.new
- ProtocolRegexp =
%r{^[-a-z]+://}.freeze
Instance Method Summary
collapse
Constructor Details
#initialize(template, controller, source, include_host = true) ⇒ AssetTag
Returns a new instance of AssetTag.
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
|
# File 'lib/action_view/helpers/asset_tag_helper.rb', line 532
def initialize(template, controller, source, include_host = true)
@template = template
@controller = controller
@source = source
@include_host = include_host
@cache_key = if controller.respond_to?(:request)
[self.class.name,controller.request.protocol,
ActionController::Base.asset_host,
ActionController::Base.relative_url_root,
source, include_host]
else
[self.class.name,ActionController::Base.asset_host, source, include_host]
end
end
|
Instance Method Details
#asset_file_path ⇒ Object
555
556
557
|
# File 'lib/action_view/helpers/asset_tag_helper.rb', line 555
def asset_file_path
File.join(ASSETS_DIR, public_path.split('?').first)
end
|
560
561
562
|
# File 'lib/action_view/helpers/asset_tag_helper.rb', line 560
def contents
File.read(asset_file_path)
end
|
564
565
566
|
# File 'lib/action_view/helpers/asset_tag_helper.rb', line 564
def mtime
File.mtime(asset_file_path)
end
|
#public_path ⇒ Object
550
551
552
|
# File 'lib/action_view/helpers/asset_tag_helper.rb', line 550
def public_path
compute_public_path(@source)
end
|