Sha256: 95bc111c78a1f503b06390fc5c63ad72013dc087d01563ecd9ded7fcae1b94bc

Contents?: true

Size: 750 Bytes

Versions: 2

Compression:

Stored size: 750 Bytes

Contents

module Intent
  module Core
    class Directory
      attr_reader :path

      def initialize(path, projects)
        @path = path
        @ledger = projects
        @record = projects.all.find { |d| d.tags[:is] == 'directory' && d.text == @path }
      end

      def project
        record.projects.first
      end

      def is_linked?
        !record.nil? && record.projects.any?
      end

      def assign!(project)
        if record.nil?
          @record = Record.new("#{Date.today} #{@path} is:directory type:#{type} sku:#{sku}")
          ledger.append(record)
        else
          record.projects << project
        end

        ledger.save!
      end

      private

      attr_reader :ledger
      attr_reader :record
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
intent-0.8.1 lib/intent/core/directory.rb
intent-0.8.0 lib/intent/core/directory.rb