-
Notifications
You must be signed in to change notification settings - Fork 5
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
Extract and refactor client #12
Conversation
fyurchik
commented
Feb 22, 2024
•
edited
Loading
edited
- Extract client class
- Refactor client class
} | ||
end | ||
|
||
def connection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need a memoization here? like:
def connection
@connection ||= Faraday.new do |faraday|
faraday.adapter Faraday.default_adapter
end
end
lib/rubyai/client.rb
Outdated
JSON.parse(response.body) | ||
end | ||
|
||
def mode(model) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Ruby, when you declare attr_accessor :model, it automatically creates both a getter and a setter method for :model. This means you have the following methods implicitly defined by that single line:
def model # This is the getter
@model
end
def model=(value) # This is the setter
@model = value
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can delete this method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
lib/rubyai/client.rb
Outdated
JSON.parse(response.body) | ||
end | ||
|
||
def mode(model) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can delete this method