Class: Isomorfeus::AssetManager::Asset
- Inherits:
-
Object
- Object
- Isomorfeus::AssetManager::Asset
- Defined in:
- lib/isomorfeus/asset_manager/asset.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#bundle_ruby_modules ⇒ Object
readonly
Returns the value of attribute bundle_ruby_modules.
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
-
#js_imports ⇒ Object
readonly
Returns the value of attribute js_imports.
-
#mtime ⇒ Object
readonly
Returns the value of attribute mtime.
-
#mutex ⇒ Object
readonly
Returns the value of attribute mutex.
-
#ruby_imports ⇒ Object
readonly
Returns the value of attribute ruby_imports.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Class Method Summary collapse
Instance Method Summary collapse
- #add_js_import(*args) ⇒ Object (also: #add_css_import)
- #add_ruby_import(*args) ⇒ Object
- #browser? ⇒ Boolean
- #bundle ⇒ Object
- #bundled! ⇒ Object
- #bundled? ⇒ Boolean
-
#initialize(target = :browser) ⇒ Asset
constructor
A new instance of Asset.
- #node? ⇒ Boolean
- #touch ⇒ Object
- #unbundle! ⇒ Object
Constructor Details
#initialize(target = :browser) ⇒ Asset
Returns a new instance of Asset.
16 17 18 19 20 21 22 23 24 |
# File 'lib/isomorfeus/asset_manager/asset.rb', line 16 def initialize(target = :browser) @target = target @mutex = Mutex.new @bundled = false @bundle_ruby_modules = {} @hash = { css: {}, js: {}} @js_imports = [] @ruby_imports = [] end |
Instance Attribute Details
#bundle_ruby_modules ⇒ Object (readonly)
Returns the value of attribute bundle_ruby_modules.
13 14 15 |
# File 'lib/isomorfeus/asset_manager/asset.rb', line 13 def bundle_ruby_modules @bundle_ruby_modules end |
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
13 14 15 |
# File 'lib/isomorfeus/asset_manager/asset.rb', line 13 def hash @hash end |
#js_imports ⇒ Object (readonly)
Returns the value of attribute js_imports.
14 15 16 |
# File 'lib/isomorfeus/asset_manager/asset.rb', line 14 def js_imports @js_imports end |
#mtime ⇒ Object (readonly)
Returns the value of attribute mtime.
14 15 16 |
# File 'lib/isomorfeus/asset_manager/asset.rb', line 14 def mtime @mtime end |
#mutex ⇒ Object (readonly)
Returns the value of attribute mutex.
14 15 16 |
# File 'lib/isomorfeus/asset_manager/asset.rb', line 14 def mutex @mutex end |
#ruby_imports ⇒ Object (readonly)
Returns the value of attribute ruby_imports.
14 15 16 |
# File 'lib/isomorfeus/asset_manager/asset.rb', line 14 def ruby_imports @ruby_imports end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
13 14 15 |
# File 'lib/isomorfeus/asset_manager/asset.rb', line 13 def target @target end |
Class Method Details
._original_new ⇒ Object
5 |
# File 'lib/isomorfeus/asset_manager/asset.rb', line 5 alias_method :_original_new, :new |
.new(target = :browser) ⇒ Object
6 7 8 9 10 |
# File 'lib/isomorfeus/asset_manager/asset.rb', line 6 def new(target = :browser) return BrowserAsset.new if target == :browser return NodeAsset.new if target == :node raise "unknown target #{traget}" end |
Instance Method Details
#add_js_import(*args) ⇒ Object Also known as: add_css_import
34 35 36 |
# File 'lib/isomorfeus/asset_manager/asset.rb', line 34 def add_js_import(*args) @js_imports << Isomorfeus::AssetManager::JsImport.new(*args) end |
#add_ruby_import(*args) ⇒ Object
39 40 41 |
# File 'lib/isomorfeus/asset_manager/asset.rb', line 39 def add_ruby_import(*args) @ruby_imports << Isomorfeus::AssetManager::RubyImport.new(*args) end |
#browser? ⇒ Boolean
26 27 28 |
# File 'lib/isomorfeus/asset_manager/asset.rb', line 26 def browser? target == :browser end |
#bundle ⇒ Object
43 44 45 |
# File 'lib/isomorfeus/asset_manager/asset.rb', line 43 def bundle @hash[:js][:js][:raw] end |
#bundled! ⇒ Object
51 52 53 |
# File 'lib/isomorfeus/asset_manager/asset.rb', line 51 def bundled! @bundled = true end |
#bundled? ⇒ Boolean
47 48 49 |
# File 'lib/isomorfeus/asset_manager/asset.rb', line 47 def bundled? @bundled end |
#node? ⇒ Boolean
30 31 32 |
# File 'lib/isomorfeus/asset_manager/asset.rb', line 30 def node? target == :node end |
#touch ⇒ Object
59 60 61 |
# File 'lib/isomorfeus/asset_manager/asset.rb', line 59 def touch @mtime = (Time.now.to_f * (10 ** 9)).to_i end |
#unbundle! ⇒ Object
55 56 57 |
# File 'lib/isomorfeus/asset_manager/asset.rb', line 55 def unbundle! @bundled = false end |