Class: ReeMapper::FieldsFilter::OnlyStrategy
- Inherits:
-
Object
- Object
- ReeMapper::FieldsFilter::OnlyStrategy
- Defined in:
- lib/ree_lib/packages/ree_mapper/package/ree_mapper/fields_filter.rb
Instance Method Summary collapse
- #allow?(field) ⇒ Boolean
-
#initialize(only, except) ⇒ OnlyStrategy
constructor
A new instance of OnlyStrategy.
Constructor Details
#initialize(only, except) ⇒ OnlyStrategy
Returns a new instance of OnlyStrategy.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ree_lib/packages/ree_mapper/package/ree_mapper/fields_filter.rb', line 5 def initialize(only, except) @fields = Set.new only.each do |item| if item.is_a? Symbol @fields << item else item.each do |key, val| @fields << key end end end if !except.nil? except.each do |item| if item.is_a? Symbol @fields.delete item else item.each do |key, val| @fields.delete key end end end end end |
Instance Method Details
#allow?(field) ⇒ Boolean
31 32 33 |
# File 'lib/ree_lib/packages/ree_mapper/package/ree_mapper/fields_filter.rb', line 31 def allow?(field) fields.include? field end |