Module: Sequel::Plugins::InputTransformer::ClassMethods
- Defined in:
- lib/sequel/plugins/input_transformer.rb
Instance Attribute Summary collapse
-
#input_transformer_order ⇒ Object
readonly
The order in which to call the input transformers.
-
#input_transformers ⇒ Object
readonly
Hash of input transformer name symbols to transformer callables.
Instance Method Summary collapse
-
#add_input_transformer(transformer_name, &block) ⇒ Object
Add an input transformer to this model.
-
#skip_input_transformer(transformer_name, *columns) ⇒ Object
Set columns that the transformer should skip.
-
#skip_input_transformer?(transformer_name, column) ⇒ Boolean
Return true if the transformer should not be called for the given column.
Instance Attribute Details
#input_transformer_order ⇒ Object (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_transformers ⇒ Object (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.
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.
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 |