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

Requesting list of segments raises TypeError exception #115

Open
jwtd opened this issue Mar 9, 2012 · 1 comment
Open

Requesting list of segments raises TypeError exception #115

jwtd opened this issue Mar 9, 2012 · 1 comment

Comments

@jwtd
Copy link

jwtd commented Mar 9, 2012

Using:
Ruby 1.9.3
garb 0.9.1

Running sample code from: https://github.com/vigetlabs/garb/wiki/Segments which is...

Garb::Management::Segment.all.each {|segment| puts "#{segment.id}:#{segment.name} => #{segment.definition}"}

Raises a TypeError exception...

/Users/jd/.rvm/gems/[email protected]/gems/garb-0.9.1/lib/garb.rb:67:in `[]': can't convert String into Integer (TypeError)
from /Users/jd/.rvm/gems/[email protected]/gems/garb-0.9.1/lib/garb.rb:67:in `block in parse_link'
from /Users/jd/.rvm/gems/[email protected]/gems/garb-0.9.1/lib/garb.rb:67:in `each'
from /Users/jd/.rvm/gems/[email protected]/gems/garb-0.9.1/lib/garb.rb:67:in `detect'
from /Users/jd/.rvm/gems/[email protected]/gems/garb-0.9.1/lib/garb.rb:67:in `parse_link'
from /Users/jd/.rvm/gems/[email protected]/gems/garb-0.9.1/lib/garb/management/segment.rb:15:in `new_from_entry'
from /Users/jd/.rvm/gems/[email protected]/gems/garb-0.9.1/lib/garb/management/segment.rb:9:in `block in all'
from /Users/jd/.rvm/gems/[email protected]/gems/garb-0.9.1/lib/garb/management/segment.rb:9:in `map'
from /Users/jd/.rvm/gems/[email protected]/gems/garb-0.9.1/lib/garb/management/segment.rb:9:in `all'
@jwtd
Copy link
Author

jwtd commented Mar 9, 2012

This monkey patch got me past the issues...

module Garb
  def parse_link(entry, rel)
    if entry['link'].is_a?(Array)
      entry['link'].detect {|link| link["rel"] == rel}['href']
    else
      entry['link']['href']
    end
  end
end

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

No branches or pull requests

1 participant