Sha256: 39019695d7d3de67561f07affa210e99b903c687262bade34e4a9460198fe240

Contents?: true

Size: 513 Bytes

Versions: 46

Compression:

Stored size: 513 Bytes

Contents

module Shipit
  module ConditionalAttributes
    extend ActiveSupport::Concern

    module ClassMethods
      def inclusion_method_for(attribute)
        @inclusion_cache ||= {}
        @inclusion_cache.fetch(attribute) do
          method = "include_#{attribute}?"
          method_defined?(method) && method
        end
      end
    end

    def filter(*)
      super.reject do |attribute|
        method = self.class.inclusion_method_for(attribute)
        method && !send(method)
      end
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
shipit-engine-0.31.0 app/serializers/concerns/shipit/conditional_attributes.rb
shipit-engine-0.30.0 app/serializers/concerns/shipit/conditional_attributes.rb
shipit-engine-0.29.0 app/serializers/concerns/shipit/conditional_attributes.rb
shipit-engine-0.28.1 app/serializers/concerns/shipit/conditional_attributes.rb
shipit-engine-0.28.0 app/serializers/concerns/shipit/conditional_attributes.rb
shipit-engine-0.27.1 app/serializers/concerns/shipit/conditional_attributes.rb
shipit-engine-0.27.0 app/serializers/concerns/shipit/conditional_attributes.rb
shipit-engine-0.26.0 app/serializers/concerns/shipit/conditional_attributes.rb
shipit-engine-0.25.1 app/serializers/concerns/shipit/conditional_attributes.rb
shipit-engine-0.25.0 app/serializers/concerns/shipit/conditional_attributes.rb
shipit-engine-0.24.0 app/serializers/concerns/shipit/conditional_attributes.rb
shipit-engine-0.23.1 app/serializers/concerns/shipit/conditional_attributes.rb
shipit-engine-0.23.0 app/serializers/concerns/shipit/conditional_attributes.rb
shipit-engine-0.22.0 app/serializers/concerns/shipit/conditional_attributes.rb
shipit-engine-0.21.0 app/serializers/concerns/shipit/conditional_attributes.rb
shipit-engine-0.20.1 app/serializers/concerns/shipit/conditional_attributes.rb
shipit-engine-0.20.0 app/serializers/concerns/shipit/conditional_attributes.rb
shipit-engine-0.19.0 app/serializers/concerns/shipit/conditional_attributes.rb
shipit-engine-0.18.1 app/serializers/concerns/shipit/conditional_attributes.rb
shipit-engine-0.18.0 app/serializers/concerns/shipit/conditional_attributes.rb