summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2022-12-09 11:05:00 -0700
committermo khan <mo@mokhan.ca>2022-12-09 11:05:00 -0700
commit0b935d24ea7da513c2cfef4e8063ad1c9fc4c24c (patch)
tree70bfa263ff0dfba64b7b279ed2db7d0dcd171f80
parentd6e9ad6ce2c6b0d1a4b8696d5e6b1cf1b8346f5d (diff)
refactor: collapse conditional with ternary
-rw-r--r--lib/scim/kit/v2/attributable.rb14
1 files changed, 4 insertions, 10 deletions
diff --git a/lib/scim/kit/v2/attributable.rb b/lib/scim/kit/v2/attributable.rb
index 5553023..21d6431 100644
--- a/lib/scim/kit/v2/attributable.rb
+++ b/lib/scim/kit/v2/attributable.rb
@@ -88,16 +88,10 @@ module Scim
end
def attribute(type, resource)
- name = type.name
- if dynamic_attributes.key?(name)
- name = type.fully_qualified_name
- else
- extend(create_module_for(type))
- end
- dynamic_attributes[name] = Attribute.new(
- type: type,
- resource: resource
- )
+ previously_defined = dynamic_attributes.key?(type.name)
+ dynamic_attributes[previously_defined ? type.fully_qualified_name : type.name] =
+ Attribute.new(type: type, resource: resource)
+ extend(create_module_for(type)) unless previously_defined
end
end
end