Class: NcsNavigator::Warehouse::Filters::RemoveIdPrefixFilter
- Inherits:
-
Object
- Object
- NcsNavigator::Warehouse::Filters::RemoveIdPrefixFilter
- Includes:
- RecordIdChangingFilterSupport
- Defined in:
- lib/ncs_navigator/warehouse/filters/remove_id_prefix_filter.rb
Overview
A filter which removes a prefix from the ID for every record of a given type. This filter is stateful and so must be instantiated.
Instance Attribute Summary
Attributes included from RecordIdChangingFilterSupport
Instance Method Summary collapse
-
#changed_id(original_id) ⇒ String
The ID with the prefix removed.
-
#initialize(configuration, options = {}) ⇒ RemoveIdPrefixFilter
constructor
Creates the filter.
Methods included from RecordIdChangingFilterSupport
Constructor Details
#initialize(configuration, options = {}) ⇒ RemoveIdPrefixFilter
Creates the filter.
In addition to the options specified here, this constructor accepts the options defined on NcsNavigator::Warehouse::Filters::RecordIdChangingFilterSupport#initialize.
20 21 22 23 |
# File 'lib/ncs_navigator/warehouse/filters/remove_id_prefix_filter.rb', line 20 def initialize(configuration, ={}) super @prefix = [:prefix] or fail 'Please specify a :prefix.' end |
Instance Method Details
#changed_id(original_id) ⇒ String
Returns the ID with the prefix removed.
28 29 30 |
# File 'lib/ncs_navigator/warehouse/filters/remove_id_prefix_filter.rb', line 28 def changed_id(original_id) original_id.sub(/\A#{@prefix}/, '') if original_id end |