Class: AppPrism::Sections::SectionsCollection

Inherits:
Array
  • Object
show all
Defined in:
lib/app_prism/sections/sections_collection.rb

Instance Method Summary collapse

Instance Method Details

#find_by(values_hash) ⇒ Object

def locator

self.first.locator.chomp(' index:0')

end



9
10
11
12
13
# File 'lib/app_prism/sections/sections_collection.rb', line 9

def find_by(values_hash)
  find do |section|
    values_hash.all? { |key, value| value === section.public_send(key) }
  end
end

#select_by(values_hash) ⇒ Object



15
16
17
18
19
20
# File 'lib/app_prism/sections/sections_collection.rb', line 15

def select_by(values_hash)
  matches = select do |section|
    values_hash.all? { |key, value| value === section.public_send(key) }
  end
  self.class[*matches]
end