Sha256: 4748c2ed3fdde38ba847ab5e983d9d1f241b6b74955f620bb9fd4d26857c2eac

Contents?: true

Size: 1.27 KB

Versions: 4

Compression:

Stored size: 1.27 KB

Contents

module RestClient
  module Jogger
    module Filters
      class Base
        include ActiveModel::Model

        attr_accessor :data, :content_type, :filters, :filter_replacement

        def self.filter_class(content_type)
          type = MIME::Types[content_type].first
          if type && type.sub_type == 'xml'
            RestClient::Jogger::Filters::Xml
          else
            RestClient::Jogger::Filters::Json
          end
        end

        def initialize(opts = {})
          super
          self.data = data.dup
        end

        def filter
          filters.each do |filter|
            filter_data filter
          end
          data
        end

        def data
          @data ||= ''
        end

        def filter_replacement
          @filter_replacement ||= RestClient::Jogger.default_filter_replacement
        end

        def filters
          @filters ||= filter_parameters
        end

        def content_type
          @content_type ||= RestClient::Jogger.default_content_type
        end

        private

        def filter_parameters
          defined?(Rails) ? Rails.configuration.filter_parameters : RestClient::Jogger.filter_parameters
        end

        def filter_data(filter)
          raise NotImplementedError
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rest-client-jogger-1.3.0 lib/rest_client/jogger/filters/base.rb
rest-client-jogger-1.2.2 lib/rest_client/jogger/filters/base.rb
rest-client-jogger-1.2.1 lib/rest_client/jogger/filters/base.rb
rest-client-jogger-1.2.0 lib/rest_client/jogger/filters/base.rb