Sha256: 79c6f8f2a814c3489e517c1c03c22c1f999b969e34fefc1eb3c307e61835672a

Contents?: true

Size: 852 Bytes

Versions: 3

Compression:

Stored size: 852 Bytes

Contents

# frozen_string_literal: true

require 'active_support/concern'

module AppStoreConnect
  module Object
    module Data
      extend ActiveSupport::Concern

      included do
        attr_reader :data

        klass = Class.new do |data|
          include Object::Attributes
          include Object::Type

          data.define_method :initialize do |**kwargs|
            instance_variable_set('@attributes', data::Attributes.new(kwargs))
          end

          def to_h
            {
              attributes: attributes.to_h,
              type: type
            }
          end
        end

        const_set('Data', klass)

        def to_h
          {
            data: data.to_h
          }
        end
      end

      class_methods do
        def data(&block)
          self::Data.class_eval(&block)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
app_store_connect-0.9.0 lib/app_store_connect/object/data.rb
app_store_connect-0.8.0 lib/app_store_connect/object/data.rb
app_store_connect-0.7.0 lib/app_store_connect/object/data.rb