Sha256: 0fd86e765b4691ca93172e1db240fc6240bb09506df0f38de2e5e2f064054e11

Contents?: true

Size: 869 Bytes

Versions: 3

Compression:

Stored size: 869 Bytes

Contents

# frozen_string_literal: true

require 'yori/schema/v3/components'
require 'yori/schema/v3/paths'

module Yori
  module Schema
    module V3
      # Provides register_component method
      class Composer
        def initialize(id)
          @id = id
        end

        attr_reader :id

        Yori::Schema::V3::Components::VALID_COMPONENTS.each do |component|
          define_method(component) do |key, value = nil, &block|
            Yori::Schema::V3::Components.register_component(id, component, key, value, &block)
          end
        end

        def path(key, value = nil, &block)
          Yori::Schema::V3::Paths.register_path(id, key, value, &block)
        end

        class << self
          def register(id = '', &block)
            composer = new(id)
            composer.instance_eval(&block)
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
yori-0.1.2 lib/yori/schema/v3/composer.rb
yori-0.1.1 lib/yori/schema/v3/composer.rb
yori-0.1.0 lib/yori/schema/v3/composer.rb