<commit_before>module Virtus
  class Attribute

    # EmbeddedValue
    #
    # @example
    #
    #   class Address
    #     include Virtus
    #
    #     attribute :street,  String
    #     attribute :zipcode, String
    #     attribute :city,    String
    #   end
    #
    #   class User
    #     include Virtus
    #
    #     attribute :address, Address
    #   end
    #
    #   user = User.new(:address => {
    #     :street => 'Street 1/2', :zipcode => '12345', :city => 'NYC' })
    #
    class EmbeddedValue < Object
      primitive ::OpenStruct

      # @see Attribute.merge_options
      #
      # @return [Hash]
      #   an updated options hash for configuring an EmbeddedValue instance
      #
      # @api private
      def self.merge_options(type, _options)
        super.update(:primitive => type)
      end

      # Determine type based on class
      #
      # Virtus::EmbeddedValue.determine_type(Struct) # => Virtus::EmbeddedValue::FromStruct
      # Virtus::EmbeddedValue.determine_type(VirtusClass) # => Virtus::EmbeddedValue::FromOpenStruct
      #
      # @param [Class] klass
      #
      # @return [Virtus::Attribute::EmbeddedValue]
      #
      # @api private
      def self.determine_type(klass)
        if klass <= Virtus || klass <= OpenStruct || klass <= Struct
          self
        end
      end

      # @api private
      def self.coercer(type, _options = {})
        if type <= Virtus || type <= OpenStruct
          OpenStructCoercer.new(type)
        elsif type <= Struct
          StructCoercer.new(type)
        else
          super
        end
      end

    end # class EmbeddedValue
  end # class Attribute
end # module Virtus<commit_msg>[wip] turn EV into an Axiom::Types::Object subclass<commit_after>module Virtus
  class Attribute

    # EmbeddedValue
    #
    # @example
    #
    #   class Address
    #     include Virtus
    #
    #     attribute :street,  String
    #     attribute :zipcode, String
    #     attribute :city,    String
    #   end
    #
    #   class User
    #     include Virtus
    #
    #     attribute :address, Address
    #   end
    #
    #   user = User.new(:address => {
    #     :street => 'Street 1/2', :zipcode => '12345', :city => 'NYC' })
    #
    class EmbeddedValue < Axiom::Types::Object
      primitive ::OpenStruct

      # @see Attribute.merge_options
      #
      # @return [Hash]
      #   an updated options hash for configuring an EmbeddedValue instance
      #
      # @api private
      def self.merge_options(type, _options)
        super.update(:primitive => type)
      end

      # Determine type based on class
      #
      # Virtus::EmbeddedValue.determine_type(Struct) # => Virtus::EmbeddedValue::FromStruct
      # Virtus::EmbeddedValue.determine_type(VirtusClass) # => Virtus::EmbeddedValue::FromOpenStruct
      #
      # @param [Class] klass
      #
      # @return [Virtus::Attribute::EmbeddedValue]
      #
      # @api private
      def self.infer(klass)
        if klass <= Virtus || klass <= OpenStruct || klass <= Struct
          self
        end
      end

      # @api private
      def self.coercer(type, _options = {})
        if type <= Virtus || type <= OpenStruct
          OpenStructCoercer.new(type)
        elsif type <= Struct
          StructCoercer.new(type)
        else
          super
        end
      end

    end # class EmbeddedValue
  end # class Attribute
end # module Virtus
{'fraction_non_alphanumeric': 0.10148731408573929, 'fraction_numerical': 0.004082822980460776, 'mean_word_length': 1.944206008583691, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4109265', 'n_tokens_mistral': 1077, 'n_tokens_neox': 1027, 'n_words': 243}