Sha256: d31d3426cc7a70e0c81ccb79a4b211e377f0abd68689b3ea2dec4e592c0721fd

Contents?: true

Size: 893 Bytes

Versions: 21

Compression:

Stored size: 893 Bytes

Contents

module Itamae
  class Definition < Resource::Base
    class << self
      attr_accessor :definition_block
      attr_accessor :defined_in_recipe

      def create_class(name, params, defined_in_recipe, &block)
        Class.new(self).tap do |klass|
          klass.definition_block = block
          klass.defined_in_recipe = defined_in_recipe

          klass.define_attribute :action, default: :run
          params.each_pair do |key, value|
            klass.define_attribute key.to_sym, type: Object, default: value
          end
        end
      end
    end

    def initialize(*args)
      super

      r = Recipe::RecipeFromDefinition.new(
        runner,
        self.class.defined_in_recipe.path,
      )
      recipe.children << r

      r.definition = self
      r.load(params: @attributes.merge(name: resource_name))
    end

    def run(*args)
      # nothing
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
itamae-1.14.1 lib/itamae/definition.rb
itamae-1.14.0 lib/itamae/definition.rb
itamae-1.13.1 lib/itamae/definition.rb
itamae-1.13.0 lib/itamae/definition.rb
itamae-1.12.6 lib/itamae/definition.rb
itamae-1.12.5 lib/itamae/definition.rb
itamae-1.12.4 lib/itamae/definition.rb
itamae-1.12.3 lib/itamae/definition.rb
itamae-1.12.2 lib/itamae/definition.rb
itamae-1.12.1 lib/itamae/definition.rb
itamae-1.12.0 lib/itamae/definition.rb
itamae-1.11.2 lib/itamae/definition.rb
itamae-1.11.1 lib/itamae/definition.rb
itamae-1.11.0 lib/itamae/definition.rb
itamae-1.10.10 lib/itamae/definition.rb
itamae-1.10.9 lib/itamae/definition.rb
itamae-1.10.8 lib/itamae/definition.rb
itamae-1.10.7 lib/itamae/definition.rb
itamae-1.10.6 lib/itamae/definition.rb
itamae-1.10.5 lib/itamae/definition.rb