Sha256: 5fa57fe878ef7e7b41ae521b41ac1dfec6eb89097678b2c0591c5f32904823fa

Contents?: true

Size: 781 Bytes

Versions: 5

Compression:

Stored size: 781 Bytes

Contents

require_relative '../models/interface'
require_relative 'repository'

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 update(name, attributes = {})
      interface = find(name)
      interface.attributes = attributes
      interface
    rescue UndefinedInterface
      create(attributes)
    end

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

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

    def entity
      Interface
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vedeu-0.0.30 lib/vedeu/repository/interface_repository.rb
vedeu-0.0.29 lib/vedeu/repository/interface_repository.rb
vedeu-0.0.28 lib/vedeu/repository/interface_repository.rb
vedeu-0.0.27 lib/vedeu/repository/interface_repository.rb
vedeu-0.0.26 lib/vedeu/repository/interface_repository.rb