lib/ecoportal/api/v2/page/components.rb in ecoportal-api-v2-0.8.8 vs lib/ecoportal/api/v2/page/components.rb in ecoportal-api-v2-0.8.9
- old
+ new
@@ -11,21 +11,26 @@
end
end
order_matters = true
+ def get_by_id(id)
+ self.find do |comp|
+ comp.id == id
+ end
+ end
+
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
+ same_string?(comp.label, name)
+ end
end
def add(label:, type:)
fld_doc = component_class.new_doc(type: type)
upsert!(fld_doc) do |fld|