Class: Accession::Configuration

Inherits:
Object
  • Object
show all
Includes:
Equality, Helpers
Defined in:
lib/accession/accession/configuration.rb

Overview

rubocop:todo Style/Documentation

Constant Summary collapse

FILES =
[:tags].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Equality

#<=>, #to_a

Methods included from Helpers

#load_file

Constructor Details

#initialize {|_self| ... } ⇒ Configuration

Returns a new instance of Configuration.

Yields:

  • (_self)

Yield Parameters:


12
13
14
15
# File 'lib/accession/accession/configuration.rb', line 12

def initialize
  @files = FILES.dup
  yield self if block_given?
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.


10
11
12
# File 'lib/accession/accession/configuration.rb', line 10

def files
  @files
end

#loadedObject (readonly)

Returns the value of attribute loaded.


10
11
12
# File 'lib/accession/accession/configuration.rb', line 10

def loaded
  @loaded
end

Instance Method Details

#add_file(file) ⇒ Object


17
18
19
20
# File 'lib/accession/accession/configuration.rb', line 17

def add_file(file)
  @files << file.to_sym
  class_eval { attr_accessor file.to_sym }
end

#attributesObject


37
38
39
# File 'lib/accession/accession/configuration.rb', line 37

def attributes
  %i[folder tags]
end

#load!Object


22
23
24
25
26
27
# File 'lib/accession/accession/configuration.rb', line 22

def load!
  if folder.present?
    FILES.each { |file| send("#{file}=", load_file(folder, file.to_s)) }
    @loaded = true
  end
end

#loaded?Boolean

Returns:

  • (Boolean)

29
30
31
# File 'lib/accession/accession/configuration.rb', line 29

def loaded?
  loaded
end

#tags=(tags) ⇒ Object


33
34
35
# File 'lib/accession/accession/configuration.rb', line 33

def tags=(tags)
  @tags = TagList.new(tags).freeze
end