Sha256: 0c1941fcc4e6d647f306d0d4af865ea3d31de174d3e08b778bc252747e94075c

Contents?: true

Size: 808 Bytes

Versions: 3

Compression:

Stored size: 808 Bytes

Contents

# frozen_string_literal: true

module Praxis
  class BlueprintAttributeGroup < Blueprint
    def self.constructable?
      true
    end

    # Construct a new subclass, using attribute_definition to define attributes.
    def self.construct(attribute_definition, options = {})
      return self if attribute_definition.nil?

      reference_type = @media_type
      # Construct a group-derived class with the given mediatype as the reference
      ::Class.new(self) do
        @reference = reference_type
        attributes(**options, &attribute_definition)
      end
    end

    def self.for(media_type)
      return media_type::AttributeGrouping if defined?(media_type::AttributeGrouping) # Cache the grouping class

      ::Class.new(self) do
        @media_type = media_type
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
praxis-2.0.pre.32 lib/praxis/blueprint_attribute_group.rb
praxis-2.0.pre.31 lib/praxis/blueprint_attribute_group.rb
praxis-2.0.pre.30 lib/praxis/blueprint_attribute_group.rb