Class: Ddr::AdminSet
- Inherits:
-
Struct
- Object
- Struct
- Ddr::AdminSet
- Defined in:
- app/models/ddr/admin_set.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
- .all ⇒ Object
- .call(obj) ⇒ Object
- .config ⇒ Object
- .find_by_code(code) ⇒ Object
- .keys ⇒ Object
- .keystore ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code
2 3 4 |
# File 'app/models/ddr/admin_set.rb', line 2 def code @code end |
#title ⇒ Object
Returns the value of attribute title
2 3 4 |
# File 'app/models/ddr/admin_set.rb', line 2 def title @title end |
Class Method Details
.all ⇒ Object
12 13 14 |
# File 'app/models/ddr/admin_set.rb', line 12 def self.all keystore.values end |
.call(obj) ⇒ Object
16 17 18 |
# File 'app/models/ddr/admin_set.rb', line 16 def self.call(obj) find_by_code(obj.admin_set) end |
.config ⇒ Object
4 5 6 |
# File 'app/models/ddr/admin_set.rb', line 4 def self.config @config ||= YAML.load_file(::File.('../../../config/aux/admin_set.yml', __dir__)) end |
.find_by_code(code) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'app/models/ddr/admin_set.rb', line 20 def self.find_by_code(code) return unless code keystore.fetch(code) rescue KeyError => _ raise Ddr::NotFoundError, "AdminSet code '#{code}' not found." end |
.keys ⇒ Object
29 30 31 |
# File 'app/models/ddr/admin_set.rb', line 29 def self.keys keystore.keys end |
.keystore ⇒ Object
8 9 10 |
# File 'app/models/ddr/admin_set.rb', line 8 def self.keystore @keystore ||= Hash[config.map { |entry| [entry['code'], new(entry).freeze] }].freeze end |
Instance Method Details
#to_s ⇒ Object
33 34 35 |
# File 'app/models/ddr/admin_set.rb', line 33 def to_s title end |