Sha256: 11aa06aae37db91388eeaef27566c2a71cb6717ec0869256e095968f375cbecc

Contents?: true

Size: 718 Bytes

Versions: 17

Compression:

Stored size: 718 Bytes

Contents

module Klaviyo
  module ClientDSL
    def define_api_method(resource:, action:)
      @@resources ||= {}

      @@resources[resource] ||
        begin
          @@resources[resource] = Class.new do
            class << self
              attr_accessor :client

              def define_action(resource, action)
                define_singleton_method action do |*args|
                  client.invoke(resource, action, *args)
                end
              end
            end
          end

          define_method resource do
            @@resources[resource].client = self
            @@resources[resource]
          end
        end

      @@resources[resource].define_action(resource, action)
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
parallel588-klaviyo-0.17.0 lib/klaviyo/client_dsl.rb
parallel588-klaviyo-0.16.0 lib/klaviyo/client_dsl.rb
parallel588-klaviyo-0.15.0 lib/klaviyo/client_dsl.rb
parallel588-klaviyo-0.14.9 lib/klaviyo/client_dsl.rb
parallel588-klaviyo-0.14.8 lib/klaviyo/client_dsl.rb
parallel588-klaviyo-0.14.5 lib/klaviyo/client_dsl.rb
parallel588-klaviyo-0.14.4 lib/klaviyo/client_dsl.rb
parallel588-klaviyo-0.14.3 lib/klaviyo/client_dsl.rb
parallel588-klaviyo-0.14.2 lib/klaviyo/client_dsl.rb
parallel588-klaviyo-0.14.1 lib/klaviyo/client_dsl.rb
parallel588-klaviyo-0.14.0 lib/klaviyo/client_dsl.rb
parallel588-klaviyo-0.13.0 lib/klaviyo/client_dsl.rb
parallel588-klaviyo-0.12.0 lib/klaviyo/client_dsl.rb
parallel588-klaviyo-0.11.0 lib/klaviyo/client_dsl.rb
parallel588-klaviyo-0.10.0 lib/klaviyo/client_dsl.rb
parallel588-klaviyo-0.9.0 lib/klaviyo/client_dsl.rb
parallel588-klaviyo-0.8.0 lib/klaviyo/client_dsl.rb