Sha256: 2b09620b950f2b774b3b8cb573766f0dbe5d7c836d2e48280564a66e9fb974ca
Contents?: true
Size: 993 Bytes
Versions: 9
Compression:
Stored size: 993 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.send(:define_method, :initialize) do |**kwargs| instance_variable_set('@relationships', kwargs.delete(:relationships).to_h) instance_variable_set('@attributes', data::Attributes.new(kwargs)) end def to_h { relationships: @relationships, 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
9 entries across 9 versions & 1 rubygems