-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Why? Currently, we have to keep creating new classes for each endpoint that spacex api launches These new classes are ***very** similar to each other This is an attempt to avoid writing the main classes. While this undeniably comes with the downsides of metaprogramming, I am wondering if we can alleviate some of that pain by continuing to write the individual specs and updating the readme file.
- Loading branch information
Showing
5 changed files
with
20 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
module SPACEX | ||
module V4 | ||
autoload :Capsules, 'spacex/v4/capsules' | ||
autoload :Company, 'spacex/v4/company' | ||
autoload :Cores, 'spacex/v4/cores' | ||
autoload :Rockets, 'spacex/v4/rockets' | ||
CLASS_NAMES = %w[Capsules Company Cores Rockets].freeze | ||
CLASS_NAMES.each do |class_name| | ||
SPACEX::V4.const_set(class_name, Class.new do |class_name| | ||
def self.info(id = nil, _query = {}) | ||
api_name = self.to_s.gsub("SPACEX::V4::", "").downcase | ||
SPACEX::BaseRequest.info("#{api_name}/#{id}", nil, 'v4') | ||
end | ||
end) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module SPACEX | ||
module V4 | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,8 @@ | |
'last_update', | ||
'launches', | ||
'serial', | ||
'id' | ||
'id', | ||
'status' | ||
) | ||
end | ||
end | ||
|