Sha256: f53dd42ade1ae88c6c3b3c49c3c87740e9ae9b6c32e3bcc79d20092d4e746683

Contents?: true

Size: 1.18 KB

Versions: 11

Compression:

Stored size: 1.18 KB

Contents

module Ironfan
  class Dsl
    class Realm < Ironfan::Dsl::Compute
      collection :clusters,       Ironfan::Dsl::Cluster,   :resolver => :deep_resolve

      magic :cluster_suffixes,    Whatever

      def self.definitions
        @realms ||= {}
      end

      def self.define(attrs = {}, &blk)
        rlm = new(attrs)
        rlm.receive!({}, &blk)
        definitions[attrs[:name].to_sym] = rlm
      end

      def initialize(attrs = {}, &blk)
        cluster_names Hash.new
        realm_name attrs[:name] if attrs[:name]
        attrs[:environment] = realm_name unless attrs.has_key?(:environment)
        super(attrs, &blk)
      end

      def cluster(label, attrs = {}, &blk)
        label = label.to_sym

        if clusters.keys.include? label
          clusters[label].tap do |cl|
            cl.receive! attrs
            cl.instance_eval(&blk) if block_given?
          end
        else
          cluster = Ironfan::Dsl::Cluster.define(name: label, owner: self, cluster_names: cluster_names)
          cluster_names[label] = label
          cluster.receive!(attrs, &blk)
          super(label, cluster)
        end
      end

      def children
        clusters.to_a
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ironfan-6.1.9 lib/ironfan/dsl/realm.rb
ironfan-6.0.9 lib/ironfan/dsl/realm.rb
ironfan-6.1.7 lib/ironfan/dsl/realm.rb
ironfan-6.1.6 lib/ironfan/dsl/realm.rb
ironfan-6.0.8 lib/ironfan/dsl/realm.rb
ironfan-6.1.5 lib/ironfan/dsl/realm.rb
ironfan-6.1.4 lib/ironfan/dsl/realm.rb
ironfan-6.1.3 lib/ironfan/dsl/realm.rb
ironfan-6.1.0 lib/ironfan/dsl/realm.rb
ironfan-6.0.7 lib/ironfan/dsl/realm.rb
ironfan-6.0.6 lib/ironfan/dsl/realm.rb