Class: Hydra::Derivatives::TransformationDirective

Inherits:
Object
  • Object
show all
Defined in:
lib/hydra/derivatives.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ TransformationDirective

Returns a new instance of TransformationDirective.

Parameters:

  • args (Hash)

    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



82
83
84
85
86
87
# File 'lib/hydra/derivatives.rb', line 82

def initialize(args)
  self.differentiator = args[:when]
  self.selector = args[:is_one_of] || args[:is]
  self.derivatives = args[:derivatives]
  self.processors = args[:processors]
end

Instance Attribute Details

#derivativesObject

Returns the value of attribute derivatives.



75
76
77
# File 'lib/hydra/derivatives.rb', line 75

def derivatives
  @derivatives
end

#differentiatorObject

Returns the value of attribute differentiator.



75
76
77
# File 'lib/hydra/derivatives.rb', line 75

def differentiator
  @differentiator
end

#processorsObject

Returns the value of attribute processors.



75
76
77
# File 'lib/hydra/derivatives.rb', line 75

def processors
  @processors
end

#selectorObject

Returns the value of attribute selector.



75
76
77
# File 'lib/hydra/derivatives.rb', line 75

def selector
  @selector
end

Instance Method Details

#applies?(object) ⇒ Boolean

Returns:

  • (Boolean)


89
90
91
# File 'lib/hydra/derivatives.rb', line 89

def applies?(object)
  selector.include?(object.send(differentiator))
end