Class: ViewAssets::Finder::Finder
- Inherits:
-
Object
- Object
- ViewAssets::Finder::Finder
- Defined in:
- lib/view_assets/finder/finder.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#assets ⇒ Object
readonly
Returns the value of attribute assets.
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#parsed_manifests ⇒ Object
readonly
Returns the value of attribute parsed_manifests.
Instance Method Summary collapse
- #empty ⇒ Object
-
#initialize ⇒ Finder
constructor
A new instance of Finder.
-
#retrieve(controller = '', action = '', options = {}) ⇒ Object
This method is the ENTRY of assets finder after its initializtion.
Constructor Details
#initialize ⇒ Finder
Returns a new instance of Finder.
16 17 18 |
# File 'lib/view_assets/finder/finder.rb', line 16 def initialize empty end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
15 16 17 |
# File 'lib/view_assets/finder/finder.rb', line 15 def action @action end |
#assets ⇒ Object (readonly)
Returns the value of attribute assets.
15 16 17 |
# File 'lib/view_assets/finder/finder.rb', line 15 def assets @assets end |
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
15 16 17 |
# File 'lib/view_assets/finder/finder.rb', line 15 def controller @controller end |
#parsed_manifests ⇒ Object (readonly)
Returns the value of attribute parsed_manifests.
15 16 17 |
# File 'lib/view_assets/finder/finder.rb', line 15 def parsed_manifests @parsed_manifests end |
Instance Method Details
#empty ⇒ Object
20 21 22 23 24 25 |
# File 'lib/view_assets/finder/finder.rb', line 20 def empty @controller = '' @action = '' @assets = [] @parsed_manifests = [] end |
#retrieve(controller = '', action = '', options = {}) ⇒ Object
This method is the ENTRY of assets finder after its initializtion. It returns all asset paths wrapped inside a appropriated html options
:controller => nil
:action => nil
:full => false
:tagged => false
TODO: need to retrive action-less assets
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/view_assets/finder/finder.rb', line 36 def retrieve(controller = '', action = '', = {}) # raise ":controller and :action can't be nil" if @controller.nil? [:full] ||= false [:tagged] ||= false @assets = [] @parsed_manifests = [] @controller = controller @action = action retrieve_controller_assets retrieve_action_assets if @action != '' @assets.uniq! @assets.map! { |asset| PathInfo.new(asset).abs } if [:full] @assets.map! { |asset| tag("/#{asset.rel}") } if [:tagged] @assets end |