Sha256: 43ba8930faed0f321fb814e435a5c57feae10f74de05b4d0a34b0093ce7f5633

Contents?: true

Size: 622 Bytes

Versions: 4

Compression:

Stored size: 622 Bytes

Contents

module CurrencyCloud
  module Actions
    module Find
      def find(params = {})
        response = client.get('find', params)
        mixin_class.new(resource, self, response)
      end

      def first(params = {})
        entities = find(params.merge(per_page: 1)) || []
        entities.first
      end

      private

      def mixin_class
        unless CurrencyCloud.const_defined?(resource.capitalize, false)
          CurrencyCloud.const_set(resource.capitalize, Class.new(CurrencyCloud::ResourcefulCollection))
        end
        CurrencyCloud.const_get(resource.capitalize, false)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
currency_cloud-1.5.0 lib/currency_cloud/actions/find.rb
currency_cloud-1.4.0 lib/currency_cloud/actions/find.rb
currency_cloud-1.3.1 lib/currency_cloud/actions/find.rb
currency_cloud-1.3.0 lib/currency_cloud/actions/find.rb