Sha256: 86c095e3f8d8002aed201d0ccab69de2eb8e4228744b31b5b0b265206fb40bc0

Contents?: true

Size: 956 Bytes

Versions: 6

Compression:

Stored size: 956 Bytes

Contents

module Builderator
  module Model
    ##
    # Shared model interface
    ##
    class Base
      attr_reader :resources
      LIMIT = 4

      def initialize(*args)
        fetch(*args)
      end

      def fetch
        @resources = {}
      end

      def find(filters = {})
        Util.filter(resources, filters)
      end

      def select(set = [])
        resources.select { |k, _| set.include?(k) }
      end

      def reject(set = [])
        resources.reject { |k, _| set.include?(k) }
      end

      def in_use(options = {})
        find(options.fetch('filters', {}))
      end

      def unused(options = {})
        Util.filter(reject(in_use(options)), options.fetch('filters', {}))
      end
    end
  end
end

require_relative './model/images'
require_relative './model/instances'
require_relative './model/launch_configs'
require_relative './model/scaling_groups'
require_relative './model/snapshots'
require_relative './model/volumes'

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
builderator-0.3.15 lib/builderator/model.rb
builderator-0.3.14 lib/builderator/model.rb
builderator-0.3.13 lib/builderator/model.rb
builderator-0.3.12 lib/builderator/model.rb
builderator-0.3.11 lib/builderator/model.rb
builderator-0.3.10 lib/builderator/model.rb