Class: ActiveAssets::ActiveExpansions::Expansion
- Inherits:
-
Object
- Object
- ActiveAssets::ActiveExpansions::Expansion
- Includes:
- AssetScope, TypeInferrable
- Defined in:
- lib/active_assets/active_expansions/expansion.rb
Instance Attribute Summary collapse
-
#assets ⇒ Object
(also: #all)
readonly
Returns the value of attribute assets.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#namespace(&blk) ⇒ Object
readonly
Returns the value of attribute namespace.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #asset(path, options = {}) ⇒ Object (also: #a, #_)
- #configure(options = {}, &blk) ⇒ Object
- #group(*groups, &blk) ⇒ Object
-
#initialize(name) ⇒ Expansion
constructor
A new instance of Expansion.
Methods included from TypeInferrable
Methods included from AssetScope
Constructor Details
#initialize(name) ⇒ Expansion
Returns a new instance of Expansion.
14 15 16 17 |
# File 'lib/active_assets/active_expansions/expansion.rb', line 14 def initialize(name) @name = name @assets = [] end |
Instance Attribute Details
#assets ⇒ Object (readonly) Also known as: all
Returns the value of attribute assets.
10 11 12 |
# File 'lib/active_assets/active_expansions/expansion.rb', line 10 def assets @assets end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/active_assets/active_expansions/expansion.rb', line 10 def name @name end |
#namespace(&blk) ⇒ Object (readonly)
Returns the value of attribute namespace.
10 11 12 |
# File 'lib/active_assets/active_expansions/expansion.rb', line 10 def namespace @namespace end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
10 11 12 |
# File 'lib/active_assets/active_expansions/expansion.rb', line 10 def type @type end |
Instance Method Details
#asset(path, options = {}) ⇒ Object Also known as: a, _
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/active_assets/active_expansions/expansion.rb', line 25 def asset(path, = {}) = HashWithIndifferentAccess.new() # map is for 1.9.2; HashWithIndifferentAccess bug? .assert_valid_keys(*Asset.members.map(&:to_s)) inferred_type, extension = inferred_type(path) .reverse_merge!( :type => inferred_type || @current_type || extension || type, :expansion_name => name, :group => @current_groups ) .update(:path => path) members = .values_at(*Asset.members) a = Asset.new(*members) a.valid! @assets << a end |
#configure(options = {}, &blk) ⇒ Object
19 20 21 22 23 |
# File 'lib/active_assets/active_expansions/expansion.rb', line 19 def configure( = {}, &blk) @type, @group, @namespace = .values_at(:type, :group, :namespace) instance_eval(&blk) if block_given? self end |
#group(*groups, &blk) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/active_assets/active_expansions/expansion.rb', line 48 def group(*groups, &blk) @current_groups = groups instance_eval(&blk) ensure @current_groups = nil end |