lib/mangadex/internal/with_attributes.rb in mangadex-5.5.6 vs lib/mangadex/internal/with_attributes.rb in mangadex-5.5.8
- old
+ new
@@ -90,10 +90,16 @@
def any_relationships?
Array(relationships).any?
end
+ def every(relationship_type)
+ Array(relationships).select do |relationship|
+ relationship.type == relationship_type.to_s
+ end
+ end
+
def method_missing(method_name, *args, **kwargs)
if self.class.attributes.include?(method_name.to_sym)
return if attributes.nil?
return unless attributes.respond_to?(method_name)
@@ -101,13 +107,13 @@
elsif any_relationships?
existing_relationships = relationships.map(&:type)
looking_for_relationship = method_name.to_s
if existing_relationships.include?(looking_for_relationship)
- result = relationships.select do |relationship|
+ relationships.find do |relationship|
relationship.type == looking_for_relationship
end
- result.size == 1 ? result.first : result
+ # result.size == 1 ? result.first : result
else
super
end
elsif !related_type.nil?
return super unless method_name.end_with?("?")