Sha256: 647aed2ccfe2f3e7d49f440dbfba6e9471a863f0e84ca1d1354f805c6e0a1ac4

Contents?: true

Size: 882 Bytes

Versions: 1

Compression:

Stored size: 882 Bytes

Contents

module ViewAssets
  module Packager
    class ActionsMap
      # @return => { :controller1 => [:action1, :action2, ..], ..}
      def retrieve
        action_path.children.select(&:directory?).each_with_object({}) do |controller, action_map|
          all_children = controller.children.map do |action|
            action.basename.to_s.chomp(action.extname)
          end

          controller_name = controller.basename.to_s
          action_map[controller.basename.to_s] = all_children.select { |action| action.to_s != controller_name }
        end
      end

      private

      def action_path
        Pathname.new(PathInfo.new("#{APP_FOLDER}/#{asset_path}").abs)
      end
    end

    class JsActionsMap < ActionsMap
      def asset_path
        JS_PATH
      end
    end

    class CssActionsMap < ActionsMap
      def asset_path
        CSS_PATH
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
view_assets-1.1.1 lib/view_assets/packager/actions_map.rb