Sha256: 91f8cfe7485a9eeb522153a6180cfa41bf103cd248c32acf87e85da680a755d8

Contents?: true

Size: 1.36 KB

Versions: 5

Compression:

Stored size: 1.36 KB

Contents

class PapermillException < Exception; end

module PapermillHashExtensions
  def deep_merge(hash)
    target = dup
    hash.keys.each do |key|
      if hash[key].is_a? Hash and self[key].is_a? Hash
        target[key] = target[key].deep_merge(hash[key])
        next
      end
      target[key] = hash[key]
    end
    target
  end
end

module PapermillObjectExtensions
  # Nil if empty.
  def nie
    self.blank? ? nil : self
  end
end

module PapermillArrayExtensions
  def map_with_index!
    each_with_index do |e, idx| self[idx] = yield(e, idx); end
  end

  def map_with_index(&block)
    dup.map_with_index!(&block)
  end
end

module PapermillFormtasticExtensions
  def image_upload_input(method, options)
    self.label(method, options_for_label(options)) +
    self.send(:image_upload, method, options)
  end
  def images_upload_input(method, options)
    self.label(method, options_for_label(options)) +
    self.send(:images_upload, method, options)
  end
  def asset_upload_input(method, options)
    self.label(method, options_for_label(options)) +
    self.send(:asset_upload, method, options)
  end
  def assets_upload_input(method, options)
    self.label(method, options_for_label(options)) +
    self.send(:assets_upload, method, options)
  end
end


module StringToUrlNotFound
  def to_url
    gsub(/[^a-zA-Z0-9]/, "-").gsub(/-+/, "-").gsub(/^-|-$/, "").downcase
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
papermill-2.1.0 lib/papermill/extensions.rb
papermill-2.0.2 lib/papermill/extensions.rb
papermill-2.0.1 lib/papermill/extensions.rb
papermill-2.0.0 lib/papermill/extensions.rb
papermill-2.0.0.pre lib/papermill/extensions.rb