Class: CommentExtractor::Configuration
- Inherits:
-
Object
- Object
- CommentExtractor::Configuration
- Defined in:
- lib/comment_extractor/configuration.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize(attributes = {}) ⇒ Configuration
Returns a new instance of Configuration.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/comment_extractor/configuration.rb', line 6 def initialize(attributes = {}) required_attributes = self.class.required_attributes.dup attributes.each do |key, value| required_attributes.delete(key) send("#{key}=", value) end unless required_attributes.empty? keys = required_attributes.keys.map { |v| ":#{v}" }.join(', ') raise ArgumentError, "Unable to initialize #{keys} without attribute" end @extractors = Extractors.default_extractors @default_extractor = Extractor::Text @use_default_extractor = true end |
Class Method Details
.add_setting(name, opts = {}) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/comment_extractor/configuration.rb', line 25 def add_setting(name, opts={}) attr_accessor name define_predicating_for(name) if opts.delete(:predicate) define_required_attribute(name) if opts.delete(:required) end |
.required_attributes ⇒ Object
32 33 34 |
# File 'lib/comment_extractor/configuration.rb', line 32 def required_attributes @required_attributes ||= {} end |