Class: Assets::Rule::Concat
- Inherits:
-
Assets::Rule
- Object
- Assets::Rule
- Assets::Rule::Concat
- Defined in:
- lib/assets/rule/concat.rb
Overview
Rule that concatenates assets from other rules
Instance Attribute Summary collapse
-
#mime ⇒ Mime
readonly
private
Return mime.
-
#name ⇒ String
readonly
private
Return name.
Class Method Summary collapse
-
.build(name, *rules) ⇒ Rule::Concat
private
Build concat rules.
-
.detect_mime(rules) ⇒ Mime
private
Detect mime type.
-
.new(name, rules) ⇒ Object
private
Instantiate object.
Instance Method Summary collapse
-
#body ⇒ String
private
Return body.
-
#updated_at ⇒ Time
private
Return updated_at.
Methods inherited from Assets::Rule
Instance Attribute Details
#mime ⇒ Mime (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return mime
21 22 23 |
# File 'lib/assets/rule/concat.rb', line 21 def mime @mime end |
#name ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return name
13 14 15 |
# File 'lib/assets/rule/concat.rb', line 13 def name @name end |
Class Method Details
.build(name, *rules) ⇒ Rule::Concat
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Build concat rules
43 44 45 |
# File 'lib/assets/rule/concat.rb', line 43 def self.build(name, *rules) new(name, rules) end |
.detect_mime(rules) ⇒ Mime
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Detect mime type
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/assets/rule/concat.rb', line 83 def self.detect_mime(rules) raise "No mime type for empty rules" if rules.empty? mime = rules.first.mime unless rules.all? { |rule| rule.mime == mime } raise 'Rules do not share mime type!' end mime end |
.new(name, rules) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Instantiate object
30 31 32 33 |
# File 'lib/assets/rule/concat.rb', line 30 def self.new(name, rules) mime = detect_mime(rules) super(name, mime, rules) end |
Instance Method Details
#body ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return body
53 54 55 |
# File 'lib/assets/rule/concat.rb', line 53 def body rules.map(&:body).join end |
#updated_at ⇒ Time
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return updated_at
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/assets/rule/concat.rb', line 63 def updated_at rules = self.rules time = rules.first.updated_at rules.each do |rule| updated_at = rule.updated_at if time < updated_at time = updated_at end end time end |