Sha256: 455c207e50076582a6e875ac9f9a0fc9b21c4f5a9ac279b39a9f6b972e3c4e0d

Contents?: true

Size: 653 Bytes

Versions: 5

Compression:

Stored size: 653 Bytes

Contents

module DynamicPaperclip
  module StyleNaming
    # Generate style name from style definition,
    # only supports strings at the moment
    def self.dynamic_style_name_from_definition(options, uri_escape=true)
      if options.is_a?(String)
        "dynamic_#{uri_escape ? URI.escape(options) : options}".to_sym
      else
        raise 'Only String options are supported with dynamic attachments'
      end
    end

    # Reverse of #dynamic_style_name_from_definition,
    # given a dynamic style name, extracts the definition (style options)
    def self.style_definition_from_dynamic_style_name(name)
      URI.unescape name[8..-1]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dynamic_paperclip-1.0.0a.3 lib/dynamic_paperclip/style_naming.rb
dynamic_paperclip-1.0.0a.2 lib/dynamic_paperclip/style_naming.rb
dynamic_paperclip-1.0.0a.1 lib/dynamic_paperclip/style_naming.rb
dynamic_paperclip-0.0.4 lib/dynamic_paperclip/style_naming.rb
dynamic_paperclip-0.0.3 lib/dynamic_paperclip/style_naming.rb