Sha256: fabd0198e5b94047e99309ccbd60ae0b0678348066caf683cd657577790130f0

Contents?: true

Size: 1.01 KB

Versions: 9

Compression:

Stored size: 1.01 KB

Contents

module Ironfan
  class Dsl

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

      def children
        clusters.to_a
      end

      magic :cluster_suffixes,    Whatever

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

      def cluster(label, attrs={},&blk)
        new_name = [realm_name, label].join('_').to_sym

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ironfan-5.0.11 lib/ironfan/dsl/realm.rb
ironfan-5.0.10 lib/ironfan/dsl/realm.rb
ironfan-5.0.8 lib/ironfan/dsl/realm.rb
ironfan-5.0.5 lib/ironfan/dsl/realm.rb
ironfan-5.0.4 lib/ironfan/dsl/realm.rb
ironfan-5.0.3 lib/ironfan/dsl/realm.rb
ironfan-5.0.2 lib/ironfan/dsl/realm.rb
ironfan-5.0.1 lib/ironfan/dsl/realm.rb
ironfan-5.0.0 lib/ironfan/dsl/realm.rb