Class: Nucleo::Models::Checks

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/nucleo/models/checks.rb

Instance Method Summary collapse

Constructor Details

#initialize(collection) ⇒ Nucleo::Models::Changes

Return an instance of the Rules collection domain model

Parameters:

  • collection (Array)


11
12
13
# File 'lib/nucleo/models/checks.rb', line 11

def initialize(collection)
  @collection = Array(collection)
end

Instance Method Details

#each(&block) ⇒ Object



15
16
17
# File 'lib/nucleo/models/checks.rb', line 15

def each(&block)
  internal_collection.each(&block)
end

#find_by_type(type) ⇒ Nucleo::Models::ChangeType

Retrieve a check by type

Returns:

  • (Nucleo::Models::ChangeType)


22
23
24
# File 'lib/nucleo/models/checks.rb', line 22

def find_by_type(type)
  self.find { |record| record.type == type }
end

#find_contentObject



26
27
28
29
30
31
# File 'lib/nucleo/models/checks.rb', line 26

def find_content
  content = self.collect { |r| r.elements.find_content }.flatten.first
  return "" if content.blank?

  content
end

#find_image_srcObject



33
34
35
# File 'lib/nucleo/models/checks.rb', line 33

def find_image_src
  self.collect { |r| r.elements.find_image_src }.flatten
end