class Rooftop::ResourceLinks::Collection

Attributes

Public Class Methods

new(links, klass=nil) click to toggle source
# File lib/rooftop/resource_links/collection.rb, line 5
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

Public Instance Methods

find_by(hash) click to toggle source

Find links by attribute. Assume there will only be one attribute in the search

# File lib/rooftop/resource_links/collection.rb, line 14
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