Class: Accession::Configuration
- Inherits:
-
Object
- Object
- Accession::Configuration
- Defined in:
- lib/accession/accession/configuration.rb
Constant Summary collapse
- FILES =
This constant defines a list of tags for loading
[:tags].freeze
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#loaded ⇒ Object
readonly
Returns the value of attribute loaded.
Instance Method Summary collapse
- #add_file(file) ⇒ Object
- #attributes ⇒ Object
-
#initialize {|_self| ... } ⇒ Configuration
constructor
A new instance of Configuration.
- #load! ⇒ Object
- #loaded? ⇒ Boolean
- #tags=(tags) ⇒ Object
Methods included from Equality
Methods included from Helpers
Constructor Details
#initialize {|_self| ... } ⇒ Configuration
Returns a new instance of Configuration.
14 15 16 17 |
# File 'lib/accession/accession/configuration.rb', line 14 def initialize @files = FILES.dup yield self if block_given? end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
12 13 14 |
# File 'lib/accession/accession/configuration.rb', line 12 def files @files end |
#loaded ⇒ Object (readonly)
Returns the value of attribute loaded.
12 13 14 |
# File 'lib/accession/accession/configuration.rb', line 12 def loaded @loaded end |
Instance Method Details
#add_file(file) ⇒ Object
19 20 21 22 |
# File 'lib/accession/accession/configuration.rb', line 19 def add_file(file) @files << file.to_sym class_eval { attr_accessor file.to_sym } end |
#attributes ⇒ Object
39 40 41 |
# File 'lib/accession/accession/configuration.rb', line 39 def attributes %i[folder tags] end |
#load! ⇒ Object
24 25 26 27 28 29 |
# File 'lib/accession/accession/configuration.rb', line 24 def load! if folder.present? FILES.each { |file| send("#{file}=", load_file(folder, file.to_s)) } @loaded = true end end |
#loaded? ⇒ Boolean
31 32 33 |
# File 'lib/accession/accession/configuration.rb', line 31 def loaded? loaded end |