Sha256: de939e378da65aa8b2c3037f52f73af08a7b7a11703ff5a6a628f3a0602db298
Contents?: true
Size: 685 Bytes
Versions: 6
Compression:
Stored size: 685 Bytes
Contents
module Rooftop module ResourceLinks class Collection < ::Array attr_reader :links def initialize(links, klass=nil) links.each do |link_type,links| links.each do |link| self << Rooftop::ResourceLinks::Link.new(link_type,link, klass) end end end # Find links by attribute. Assume there will only be one attribute in the search def find_by(hash) raise ArgumentError, "you can only find a resource link by one attribute at a time" unless hash.length == 1 attr = hash.first.first val = hash.first.last self.select {|l| l.send(attr) == val.to_s} end end end end
Version data entries
6 entries across 6 versions & 1 rubygems