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

Hyperclient sample for README #9

Open
dblock opened this issue Sep 25, 2016 · 1 comment
Open

Hyperclient sample for README #9

dblock opened this issue Sep 25, 2016 · 1 comment

Comments

@dblock
Copy link
Member

dblock commented Sep 25, 2016

This doesn't work (on the with-mongoid branch) for _post.

require 'hyperclient'

client = Hyperclient.new('http://localhost:9292/api')

3.times do |i|
  client.splines._post(spline: { name: i.to_s, reticulated: [true, false].sample })
end

client.splines.each do |spline|
  puts "spline #{spline.id} #{spline.reticulated ? 'is' : 'is not'} reticulated"
end

client.splines.each(&:_delete)
@dblock
Copy link
Member Author

dblock commented Sep 25, 2016

splines = client.splines
while splines
  splines._embedded.splines.each do |spline|
    puts "spline #{spline.id} #{spline.reticulated ? 'is' : 'is not'} reticulated"
  end

  break unless splines._links[:next]
  splines = splines._links.next
end

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

No branches or pull requests

1 participant