module Ecoportal module API class V2 class Page class Components < Common::Content::CollectionModel class_resolver :component_class, "Ecoportal::API::V2::Page::Component" self.klass do |doc| component_class.get_class(doc).tap do |klass| klass.key = :id 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