Class: ContextExposer::Integrations::KeyFilter
- Inherits:
-
Object
- Object
- ContextExposer::Integrations::KeyFilter
- Defined in:
- lib/context_exposer/integrations/key_filter.rb
Instance Attribute Summary collapse
-
#keys ⇒ Object
readonly
Returns the value of attribute keys.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #except ⇒ Object
-
#filter ⇒ Object
expose all exposures exposed by decent_exposure to context.
-
#initialize(keys, options = {}) ⇒ KeyFilter
constructor
A new instance of KeyFilter.
- #only ⇒ Object
- #symbolize_opts(name) ⇒ Object
Constructor Details
#initialize(keys, options = {}) ⇒ KeyFilter
Returns a new instance of KeyFilter.
6 7 8 9 |
# File 'lib/context_exposer/integrations/key_filter.rb', line 6 def initialize keys, = {} @keys = keys || [] @options = end |
Instance Attribute Details
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
4 5 6 |
# File 'lib/context_exposer/integrations/key_filter.rb', line 4 def keys @keys end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/context_exposer/integrations/key_filter.rb', line 4 def @options end |
Instance Method Details
#except ⇒ Object
17 18 19 |
# File 'lib/context_exposer/integrations/key_filter.rb', line 17 def except @except ||= symbolize_opts :except end |
#filter ⇒ Object
expose all exposures exposed by decent_exposure to context
12 13 14 15 |
# File 'lib/context_exposer/integrations/key_filter.rb', line 12 def filter the_keys = keys - except only.empty? ? the_keys : the_keys.select {|k| only.include? k.to_sym } end |
#only ⇒ Object
21 22 23 |
# File 'lib/context_exposer/integrations/key_filter.rb', line 21 def only @only ||= symbolize_opts :only end |
#symbolize_opts(name) ⇒ Object
25 26 27 |
# File 'lib/context_exposer/integrations/key_filter.rb', line 25 def symbolize_opts name ([name.to_sym] || {}).map(&:to_sym) end |