Class: Accession::Configuration

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

Constant Summary collapse

FILES =
[:tags]

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:


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

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

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files


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

def files
  @files
end

#loadedObject (readonly)

Returns the value of attribute loaded


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

def loaded
  @loaded
end

Instance Method Details

#add_file(file) ⇒ Object


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

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

#attributesObject


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

def attributes
  [:folder, :tags]
end

#load!Object


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

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

#loaded?Boolean


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

def loaded?
  loaded
end

#tags=(tags) ⇒ Object


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

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