Class: Mongoid::Config::Introspection::Option Private
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/mongoid/config/introspection.rb |
Overview
A helper class to represent an individual option, its name, its default value, and the comment that documents it.
Class Method Summary
-
.from_captures(captures) ⇒ Option
Internal use only
Instantiate an option from an array of Regex captures.
-
.new(name, default, comment) ⇒ Option
constructor
Internal use only
Create a new
Option
instance with the given name, default value, and comment.
Instance Attribute Summary
-
#comment ⇒ String
readonly
Internal use only
The comment that describes this option, as scraped from mongoid/config.rb.
-
#default ⇒ Object
readonly
Internal use only
The default value of this option.
-
#deprecated? ⇒ true | false
readonly
Internal use only
Reports whether or not the text “(Deprecated)” is present in the option’s comment.
-
#name ⇒ String
readonly
Internal use only
The name of this option.
Instance Method Summary
-
#==(option) ⇒ true | false
Internal use only
Compare self with the given option.
-
#indented_comment(indent: 2, indent_first_line: false) ⇒ String
Internal use only
Indent the comment by the requested amount, optionally indenting the first line, as well.
-
#unindent(text) ⇒ String
private
Internal use only
Removes any existing whitespace from the beginning of each line in the text.
Constructor Details
.new(name, default, comment) ⇒ Option
Create a new Option
instance with the given name, default value, and comment.
Class Method Details
.from_captures(captures) ⇒ Option
Instantiate an option from an array of Regex captures.
# File 'lib/mongoid/config/introspection.rb', line 46
def self.from_captures(captures) new(captures[2], captures[3], captures[1]) end
Instance Attribute Details
#comment ⇒ String (readonly)
The comment that describes this option, as scraped from mongoid/config.rb.
# File 'lib/mongoid/config/introspection.rb', line 36
attr_reader :comment
#default ⇒ Object
(readonly)
The default value of this option.
# File 'lib/mongoid/config/introspection.rb', line 29
attr_reader :default
#deprecated? ⇒ true
| false
(readonly)
Reports whether or not the text “(Deprecated)” is present in the option’s comment.
# File 'lib/mongoid/config/introspection.rb', line 81
def deprecated? comment.include?("(Deprecated)") end
#name ⇒ String (readonly)
The name of this option.
# File 'lib/mongoid/config/introspection.rb', line 23
attr_reader :name
Instance Method Details
#==(option) ⇒ true
| false
Compare self with the given option.
#indented_comment(indent: 2, indent_first_line: false) ⇒ String
# File 'lib/mongoid/config/introspection.rb', line 71
def indented_comment(indent: 2, indent_first_line: false) comment.gsub(/^/, " " * indent).tap do |result| result.strip! unless indent_first_line end end
#unindent(text) ⇒ String (private)
Removes any existing whitespace from the beginning of each line in the text.
# File 'lib/mongoid/config/introspection.rb', line 103
def unindent(text) text.strip.gsub(/^\s+/, "") end