Sha256: e3add33260f68b6f0de9ca62b52c55126bb97dabf7d141e03accdc5612e0484a

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

module Compressible
  module Assetable
    
    def self.included(base)
      base.extend ClassMethods
    end
    
    module ClassMethods
  
      def javascripts(hash)
        hash.each do |to, paths|
          paths << {:to => to}
          javascript(*paths)
        end
      end
      alias_method :add_javascripts, :javascripts

      def stylesheets(hash)
        hash.each do |to, paths|
          paths << {:to => to}
          stylesheet(*paths)
        end
      end
      alias_method :add_stylesheets, :stylesheets
  
      def javascript(*args)
        paths = args.dup
        options = paths.extract_options!
        to = asset_name(options[:to])
        raise "Please define a name for the cached javascript using ':to => :my_name'" unless to

        add_to_config(:js, to, paths)
        
        write_javascript(*args) unless config[:read_only] == true
      end
      alias_method :add_javascript, :javascript
      alias_method :js, :javascript

      def stylesheet(*args)
        paths = args.dup
        options = paths.extract_options!
        to = asset_name(options[:to])
        add_to_config(:css, to, paths)
        write_stylesheet(*args) unless config[:read_only] == true
      end
      alias_method :add_stylesheet, :stylesheet
      alias_method :css, :stylesheet
      
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
compressible-0.0.2.3 lib/compressible/assetable.rb