Skip to content
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

Merged
merged 5 commits into from
Feb 27, 2024
Merged

Conversation

fyurchik
Copy link
Collaborator

@fyurchik fyurchik commented Feb 22, 2024

  • Extract client class
  • Refactor client class

@fyurchik fyurchik self-assigned this Feb 22, 2024
@fyurchik fyurchik linked an issue Feb 22, 2024 that may be closed by this pull request
}
end

def connection
Copy link
Collaborator Author

@fyurchik fyurchik Feb 22, 2024

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 

JSON.parse(response.body)
end

def mode(model)
Copy link
Owner

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

Copy link
Owner

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

JSON.parse(response.body)
end

def mode(model)
Copy link
Owner

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

@sanyakosivchuk sanyakosivchuk merged commit 268f703 into main Feb 27, 2024
1 check passed
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.

Refactor and extract client.rb
3 participants