Class: GeneratedAssets::Entry
- Inherits:
-
Object
- Object
- GeneratedAssets::Entry
- Defined in:
- lib/generated-assets/entry.rb
Constant Summary collapse
- DEFAULT_PROC =
Proc.new { '' }
Instance Attribute Summary collapse
-
#callback ⇒ Object
readonly
Returns the value of attribute callback.
-
#logical_path ⇒ Object
readonly
Returns the value of attribute logical_path.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(logical_path, callback, options = {}) ⇒ Entry
constructor
A new instance of Entry.
- #precompile? ⇒ Boolean
- #write_to(prefix) ⇒ Object
Constructor Details
#initialize(logical_path, callback, options = {}) ⇒ Entry
Returns a new instance of Entry.
11 12 13 14 15 |
# File 'lib/generated-assets/entry.rb', line 11 def initialize(logical_path, callback, = {}) @logical_path = logical_path @callback = callback || DEFAULT_PROC @options = end |
Instance Attribute Details
#callback ⇒ Object (readonly)
Returns the value of attribute callback.
9 10 11 |
# File 'lib/generated-assets/entry.rb', line 9 def callback @callback end |
#logical_path ⇒ Object (readonly)
Returns the value of attribute logical_path.
9 10 11 |
# File 'lib/generated-assets/entry.rb', line 9 def logical_path @logical_path end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/generated-assets/entry.rb', line 9 def @options end |
Instance Method Details
#precompile? ⇒ Boolean
17 18 19 |
# File 'lib/generated-assets/entry.rb', line 17 def precompile? @options.fetch(:precompile, false) end |
#write_to(prefix) ⇒ Object
21 22 23 24 25 |
# File 'lib/generated-assets/entry.rb', line 21 def write_to(prefix) path = File.join(prefix, logical_path) FileUtils.mkdir_p(File.dirname(path)) File.binwrite(path, callback.call) end |