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.



46
47
48
# File 'lib/sequel/plugins/input_transformer.rb', line 46

def input_transformer_order
  @input_transformer_order
end

#input_transformersObject (readonly)

Hash of input transformer name symbols to transformer callables.



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

def input_transformers
  @input_transformers
end

Instance Method Details

#add_input_transformer(transformer_name, &block) ⇒ Object

Add an input transformer to this model.

Raises:



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

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.



59
60
61
# File 'lib/sequel/plugins/input_transformer.rb', line 59

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)


64
65
66
# File 'lib/sequel/plugins/input_transformer.rb', line 64

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