lib/ecoportal/api/v2/page/components.rb in ecoportal-api-oozes-0.5.5 vs lib/ecoportal/api/v2/page/components.rb in ecoportal-api-oozes-0.5.6
- old
+ new
@@ -11,9 +11,23 @@
end
end
order_matters = true
+ def get_by_type(type)
+ self.select do |comp|
+ comp.type.downcase == type.to_s.strip.downcase
+ end
+ end
+
+ def get_by_name(name, type: nil)
+ pool = type ? get_by_type(type) : self
+
+ pool.select do |comp|
+ comp.label.to_s.strip.downcase == name.to_s.strip.downcase
+ end.first
+ end
+
end
end
end
end
end