Sha256: 3894bc680f7d869eae33b9e5f3fddea4da639f03518977411f0ed0d2b828b6e6

Contents?: true

Size: 778 Bytes

Versions: 4

Compression:

Stored size: 778 Bytes

Contents

module Vedeu
  class UndefinedInterface < StandardError; end

  module InterfaceRepository
    extend Repository
    extend self

    def create(attributes = {})
      super(Interface.new(attributes))
    end

    def find(name)
      result = super
      raise UndefinedInterface unless result
      result
    end

    def refresh
      by_layer.map { |interface| interface.refresh }.compact
    end

    def by_layer
      all.sort_by { |interface| interface.layer }
    end

    def entity
      Interface
    end
  end

  # :nocov:
  module ClassMethods
    def interface(name, options = {})
      interface_name = name.is_a?(Symbol) ? name.to_s : name

      InterfaceRepository.create({
        name: interface_name
      }.merge!(options))
    end
  end
  # :nocov:
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vedeu-0.0.25 lib/vedeu/repository/interface_repository.rb
vedeu-0.0.24 lib/vedeu/repository/interface_repository.rb
vedeu-0.0.23 lib/vedeu/repository/interface_repository.rb
vedeu-0.0.22 lib/vedeu/repository/interface_repository.rb