Sha256: 1a515b0b623a51d2da89923e53b193d26f2fa1e64909a49a5bcc4874fe747555

Contents?: true

Size: 737 Bytes

Versions: 9

Compression:

Stored size: 737 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?

      # Construct a group-derived class with the given mediatype as the reference
      ::Class.new(self) do
        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

9 entries across 9 versions & 1 rubygems

Version Path
praxis-2.0.0 lib/praxis/blueprint_attribute_group.rb
praxis-2.0.pre.40 lib/praxis/blueprint_attribute_group.rb
praxis-2.0.pre.39 lib/praxis/blueprint_attribute_group.rb
praxis-2.0.pre.38 lib/praxis/blueprint_attribute_group.rb
praxis-2.0.pre.37 lib/praxis/blueprint_attribute_group.rb
praxis-2.0.pre.36 lib/praxis/blueprint_attribute_group.rb
praxis-2.0.pre.35 lib/praxis/blueprint_attribute_group.rb
praxis-2.0.pre.34 lib/praxis/blueprint_attribute_group.rb
praxis-2.0.pre.33 lib/praxis/blueprint_attribute_group.rb