Skip to content

Instantly share code, notes, and snippets.

@pxnky

pxnky/x.rb Secret

Last active July 3, 2019 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pxnky/9517dfa2b9be2ea676cc059df46e5957 to your computer and use it in GitHub Desktop.
Save pxnky/9517dfa2b9be2ea676cc059df46e5957 to your computer and use it in GitHub Desktop.
class API
def initialize(...)
@faraday = Faraday.new(...) do |c|
c.blahblah
end
end
def getspecificthings
@faraday.get('specificthings').body.map {|x| SpecificAPIThing(x) }
end
class GenericAPIThing
def initialize(name)
@name = name
end
class SpecificAPIThing < GenericAPIThing
def initialize(*)
super
end
def actionforspecificthing(var)
@faraday.get(var)
end
end
end
@havenwood
Copy link

class API
  def initialize(name, *)
    @name = name
    @faraday = Faraday.new(*) do |c|
      c.blahblah
    end
  end
	
  def get_specific_things
    @faraday.get('specificthings').body.map { |x| SpecificAPIThing(x) }
  end
end

class SpecificAPI < API
  def initialize(*)
    super
  end

  def action_for_specific_thing(var)
    @faraday.get(var)
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment