Class: ActiveAssets::ActiveExpansions::Expansions
- Inherits:
-
Object
- Object
- ActiveAssets::ActiveExpansions::Expansions
- Includes:
- AssetScope, Configurable, TypeInferrable, ActiveSupport::Configurable
- Defined in:
- lib/active_assets/active_expansions/expansions.rb
Instance Method Summary collapse
- #all ⇒ Object
- #asset(path, options = {}) ⇒ Object (also: #a, #_)
- #clear ⇒ Object
- #expansion(name, options = {}, &blk) ⇒ Object
-
#initialize ⇒ Expansions
constructor
A new instance of Expansions.
- #javascripts ⇒ Object
- #namespace(name, &blk) ⇒ Object
- #register(&blk) ⇒ Object
- #stylesheets ⇒ Object
Methods included from TypeInferrable
Methods included from AssetScope
Constructor Details
#initialize ⇒ Expansions
Returns a new instance of Expansions.
12 13 14 |
# File 'lib/active_assets/active_expansions/expansions.rb', line 12 def initialize @expansions = Hash.new(&method(:build_expansions_hash_with_defaults)) end |
Instance Method Details
#all ⇒ Object
66 67 68 |
# File 'lib/active_assets/active_expansions/expansions.rb', line 66 def all @expansions[:js].values + @expansions[:css].values end |
#asset(path, options = {}) ⇒ Object Also known as: a, _
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/active_assets/active_expansions/expansions.rb', line 28 def asset(path, = {}) deferred_expansion_name, = @deferred_expansion_config inferred_type, extension = inferred_type(path) = HashWithIndifferentAccess.new().reverse_merge( :type => inferred_type || @current_type, :expansion_name => deferred_expansion_name, :group => @current_groups ) = ( || {}, [:type]) # asset call below is executed in the scope of the ActiveAssets::Expansion @expansions[[:type] || extension][[:expansion_name]].configure() do asset(path, ) end end |
#clear ⇒ Object
70 71 72 |
# File 'lib/active_assets/active_expansions/expansions.rb', line 70 def clear @expansions.clear end |
#expansion(name, options = {}, &blk) ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/active_assets/active_expansions/expansions.rb', line 48 def expansion(name, = {}, &blk) = () if [:type].present? @expansions[[:type]][name].configure(, &blk) else defer_expansion(name, , &blk) end end |
#javascripts ⇒ Object
58 59 60 |
# File 'lib/active_assets/active_expansions/expansions.rb', line 58 def javascripts Javascripts.new(@expansions[:js]) end |
#namespace(name, &blk) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/active_assets/active_expansions/expansions.rb', line 21 def namespace(name, &blk) @current_namespace = name instance_eval(&blk) ensure @current_namespace = nil end |
#register(&blk) ⇒ Object
16 17 18 19 |
# File 'lib/active_assets/active_expansions/expansions.rb', line 16 def register(&blk) instance_eval(&blk) if block_given? self end |
#stylesheets ⇒ Object
62 63 64 |
# File 'lib/active_assets/active_expansions/expansions.rb', line 62 def stylesheets Stylesheets.new(@expansions[:css]) end |