Skip to content

DOCSP-45187: Update #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Dec 16, 2024
Merged

Conversation

mcmorisi
Copy link
Collaborator

@mcmorisi mcmorisi commented Dec 11, 2024

Pull Request Info

PR Reviewing Guidelines

JIRA - https://jira.mongodb.org/browse/DOCSP-45187

Staging Links

  • write
  • write/update
  • index
  • Self-Review Checklist

    • Is this free of any warnings or errors in the RST?
    • Did you run a spell-check?
    • Did you run a grammar-check?
    • Are all the links working?
    • Are the facets and meta keywords accurate?

    Copy link

    netlify bot commented Dec 11, 2024

    Deploy Preview for docs-ruby ready!

    Name Link
    🔨 Latest commit f2ecc5f
    🔍 Latest deploy log https://app.netlify.com/sites/docs-ruby/deploys/676030e01fac9c0008793628
    😎 Deploy Preview https://deploy-preview-98--docs-ruby.netlify.app
    📱 Preview on mobile
    Toggle QR Code...

    QR Code

    Use your smartphone camera to open QR code link.

    To edit notification comments on pull requests, go to your Netlify site configuration.

    Copy link
    Collaborator

    @mongoKart mongoKart left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    does it smell like update in here

    Comment on lines +1 to +5
    require 'bundler/inline'
    gemfile do
    source 'https://rubygems.org'
    gem 'mongo'
    end
    Copy link
    Collaborator

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Q: have we gotten any guidance from the ruby team about bundler vs. just require 'mongo'?

    Copy link
    Collaborator Author

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Not sure – I'm going off the Quick Start (which shows the use of bundler), which I assumed had been tech reviewed.

    Copy link
    Contributor

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Using bundler definitely describes a more complete picture, but for example scripts I think it's sufficient to just require 'mongo', personally.

    @mcmorisi mcmorisi requested a review from mongoKart December 12, 2024 20:13
    Copy link
    Collaborator

    @mongoKart mongoKart left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    LGTM w/ a few suggestions!

    Comment on lines +24 to +25
    documents in a MongoDB collection by using the ``update_one`` and
    ``update_many`` methods.
    Copy link
    Collaborator

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Q: most of our docs include parentheses after a method name; is there something different about ruby?

    Copy link
    Collaborator Author

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    I asked Nora about this – it seems like current Ruby documentation avoids using parentheses. The language in general seems more relaxed about using parentheses in code.

    Copy link
    Contributor

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Parentheses are largely optional in Ruby, as long as the meaning is unambiguous. By convention, parentheses are almost always omitted when a method call has no parameters (e.g file.close). Otherwise, Rubyists often omit parentheses when there is only a single literal argument (e.g. puts "hello") or with keyword arguments (e.g. foo a: 1, b: "two"). It becomes a stylistic concern at that point.

    Asking MongoGPT about it, the all-knowing AI suggests the following:

    In Ruby, omitting parentheses for method arguments is common, especially in certain contexts where it enhances readability and maintains a more natural syntax. Here are some conventions and guidelines that developers often follow when deciding whether to omit parentheses:

    1. DSLs (Domain-Specific Languages): When designing or using DSLs, parentheses are often omitted to create a syntax that reads more like a natural language. This is common in frameworks like Rails, particularly in routing and validation declarations.

    2. Control Structures: For built-in Ruby control structures such as if, while, until, and case, parentheses are typically omitted around their conditions to improve readability and maintain a cleaner syntax.

    3. Short Methods: When calling methods that take no arguments or only a single simple argument, it is common to omit parentheses to streamline the code. For example:

      puts "Hello, world"
    4. Internal DSLs or Configure Blocks: In configurations or setup blocks (e.g., Rake tasks, ActiveRecord scopes), omitting parentheses can make the code easier to follow and more domain-centric.

    5. Chaining Methods: When method calls are chained, parentheses are usually omitted for the first method call if it takes a single argument, leading to a more fluid syntax.

    6. Readability: Parentheses can be omitted when they enhance readability by removing unnecessary clutter, especially in expressions that are clearly understood without them.

    However, there are also scenarios where including parentheses is preferred:

    • Ambiguity: If omitting parentheses leads to ambiguity or confusion about the order of operations, it is better to include them.
    • Multi-Argument Methods: When a method takes multiple arguments, especially with complex expressions, using parentheses can make the argument list clearer.
    • Precedence Issues: In expressions with complex operator precedence, including parentheses can clarify the intended order of operations.
    • Method Definitions: When defining methods, it's common to use parentheses for the argument list to clearly specify the parameters, even though it is optional.

    Ultimately, the decision to omit parentheses often comes down to personal or team styling preferences, but developers should aim for consistency and clarity in their code.

    For more information, see the :manual:`hint statement </reference/command/update/#std-label-update-command-hint>`
    in the {+mdb-server+} manual.

    * - ``let``
    - | Provides a map of parameter names and values to set top-level
    - | A map of parameter names and values to set top-level
    Copy link
    Collaborator

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Suggested change
    - | A map of parameter names and values to set top-level
    - | Map of parameter names and values to set top-level


    * - ``collation``
    - | Specifies the kind of language collation to use when sorting
    - | The kind of language collation to use when sorting
    Copy link
    Collaborator

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Suggested change
    - | The kind of language collation to use when sorting
    - | Language collation to use when sorting

    doesn't match any existing documents.
    Because the ``upsert`` option is set to ``true``, if the query filter
    doesn't match any existing documents, the driver inserts a new document that
    has the fields and values in the filter and update documents.
    Copy link
    Collaborator

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    S:

    Suggested change
    has the fields and values in the filter and update documents.
    contains the fields and values in the filter and update documents.

    @mcmorisi mcmorisi merged commit 5ab69e7 into mongodb:standardization Dec 16, 2024
    1 check passed
    @mcmorisi mcmorisi deleted the DOCSP-45187-update branch December 16, 2024 13:53
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    3 participants