Module: Sequel::Plugins::InputTransformer::ClassMethods

Defined in:
lib/sequel/plugins/input_transformer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#input_transformer_orderObject (readonly)

The order in which to call the input transformers.



44
45
46
# File 'lib/sequel/plugins/input_transformer.rb', line 44

def input_transformer_order
  @input_transformer_order
end

#input_transformersObject (readonly)

Hash of input transformer name symbols to transformer callables.



41
42
43
# File 'lib/sequel/plugins/input_transformer.rb', line 41

def input_transformers
  @input_transformers
end

Instance Method Details

#add_input_transformer(transformer_name, &block) ⇒ Object

Add an input transformer to this model.

Raises:



49
50
51
52
53
54
# File 'lib/sequel/plugins/input_transformer.rb', line 49

def add_input_transformer(transformer_name, &block)
  raise(Error, 'must provide both transformer name and block when adding input transformer') unless transformer_name && block
  @input_transformers[transformer_name] = block
  @input_transformer_order.unshift(transformer_name)
  @skip_input_transformer_columns[transformer_name] = []
end

#skip_input_transformer(transformer_name, *columns) ⇒ Object

Set columns that the transformer should skip.



57
58
59
# File 'lib/sequel/plugins/input_transformer.rb', line 57

def skip_input_transformer(transformer_name, *columns)
  @skip_input_transformer_columns[transformer_name].concat(columns).uniq!
end

#skip_input_transformer?(transformer_name, column) ⇒ Boolean

Return true if the transformer should not be called for the given column.

Returns:

  • (Boolean)


62
63
64
# File 'lib/sequel/plugins/input_transformer.rb', line 62

def skip_input_transformer?(transformer_name, column)
  @skip_input_transformer_columns[transformer_name].include?(column)
end