Class: ActiveInteraction::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/mtk_framework/gem_extensions/active_interaction/base.rb,
lib/mtk_framework/gem_extensions/active_interaction/filters/tz_account_filter.rb,
lib/mtk_framework/gem_extensions/active_interaction/filters/tz_operation_filter.rb,
lib/mtk_framework/gem_extensions/active_interaction/filters/tz_signature_filter.rb,
lib/mtk_framework/gem_extensions/active_interaction/filters/tz_public_key_filter.rb,
lib/mtk_framework/gem_extensions/active_interaction/filters/tz_secret_key_filter.rb,
lib/mtk_framework/gem_extensions/active_interaction/filters/tz_contract_address_filter.rb

Class Method Summary collapse

Class Method Details

.import_filters_optionally(klass, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/mtk_framework/gem_extensions/active_interaction/base.rb', line 5

def self.import_filters_optionally(klass, options = {})
  only = options[:only]
  except = options[:except]
  default_value = options[:default_value]

  other_filters = klass.filters.dup
  other_filters.select! { |k, _| [*only].include?(k) } if only
  other_filters.reject! { |k, _| [*except].include?(k) } if except

  other_filters.each_value do |filter|
    filter.options[:default] = default_value
    initialize_filter(filter)
  end
end