Sha256: 2ec4890130c2edf1137987a3425de218279f155bcada5f3c98f0c423e79f5bf2

Contents?: true

Size: 705 Bytes

Versions: 1

Compression:

Stored size: 705 Bytes

Contents

module AppManifest
  # A simple model-like wrapper around a manifest hash.
  class Manifest
    include Virtus.model
    include EnvironmentAttributes
    include Serializer

    attribute :environments, Hash[String => Environment], default: nil

    def self.from_json(string)
      hash = MultiJson.load(string)
      new(hash)
    end

    def initialize(hash)
      canonicalized = AppManifest.canonicalize(hash)
      super(canonicalized)
    end

    def environment(name)
      scoped_data = (environments || {}).fetch(name.to_s, {}).to_hash
      global_data = to_hash
      Environment.new(global_data.merge(scoped_data))
    end

    def environments?
      !environments.nil?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
app_manifest-0.5.0 lib/app_manifest/manifest.rb