Module: Hydra::Derivatives::ClassMethods

Defined in:
lib/hydra/derivatives.rb

Instance Method Summary collapse

Instance Method Details

#makes_derivatives_of(datastream, args = {}) ⇒ Object

Examples:

makes_derivatives_of :content, when: :mime_type, is: 'text/pdf',
    derivatives: { :text => { :quality => :better }, processors: [:ocr]}

makes_derivatives_of :content, when: :mime_type, is_one_of: ['image/png', 'image/jpg'],
    derivatives: { :medium => "300x300>", :thumb => "100x100>" }

Parameters:

  • datastream (Symbol, String)

    the datastream to operate on

  • args (Hash) (defaults to: {})

    the options

Options Hash (args):

  • :when (Symbol)

    the method that holds the differentiator column

  • :is_one_of (String, Array)

    activates this set of derivatives when the the differentiator column is includes one of these.

  • :is (String, Array)

    alias for :is_one_of

  • :derivatives (Hash)

    the derivatives to be produced

  • :processors (Symbol, Array)

    the processors to run to produce the derivatives



108
109
110
111
112
# File 'lib/hydra/derivatives.rb', line 108

def makes_derivatives_of(datastream, args = {})
  self.transformation_scheme ||= {}
  self.transformation_scheme[datastream.to_sym] ||= []
  self.transformation_scheme[datastream.to_sym] << TransformationDirective.new(args)
end