Sha256: bb01a483040500fa37595bef059991749feb2a23368ce8f69f33e71ff00388fc

Contents?: true

Size: 1.11 KB

Versions: 7

Compression:

Stored size: 1.11 KB

Contents

require 'active_support/core_ext/string/inflections'

module Octoparts
  module Representer
    class Camelizer
      include Uber::Callable
      def initialize(camelcase)
        @camelcase = camelcase
      end

      def call(_represented, args)
        args[:camelize] ? @camelcase : @camelcase.underscore
      end
    end

    module AggregateRequestRepresenter
      include Representable::JSON

      property :request_meta, as: Camelizer.new('requestMeta'), class: Model::RequestMeta do
        property :id
        property :service_id, as: Camelizer.new('serviceId')
        property :user_id, as: Camelizer.new('userId')
        property :session_id, as: Camelizer.new('sessionId')
        property :request_url, as: Camelizer.new('requestUrl')
        property :user_agent, as: Camelizer.new('userAgent')
        property :timeout
      end

      collection :requests, class: Model::PartRequest do
        property :part_id, as: Camelizer.new('partId')
        property :id
        collection :params, class: Model::PartRequestParam do
          property :key
          property :value
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
octoparts-0.0.8 lib/octoparts/representer/aggregate_request_representer.rb
octoparts-0.0.7 lib/octoparts/representer/aggregate_request_representer.rb
octoparts-0.0.6 lib/octoparts/representer/aggregate_request_representer.rb
octoparts-0.0.5 lib/octoparts/representer/aggregate_request_representer.rb
octoparts-0.0.4 lib/octoparts/representer/aggregate_request_representer.rb
octoparts-0.0.3 lib/octoparts/representer/aggregate_request_representer.rb
octoparts-0.0.2 lib/octoparts/representer/aggregate_request_representer.rb