Commit 83274c9
Changed files (5)
lib
scim
kit
lib/scim/kit/v2/templates/supportable.json.jbuilder
@@ -2,6 +2,6 @@
json.key_format! camelize: :lower
json.supported supported
-@custom_attributes.each do |key, value|
+@dynamic_attributes.each do |key, value|
json.set! key.to_s.delete('='), value
end
lib/scim/kit/v2/supportable.rb
@@ -6,27 +6,16 @@ module Scim
# Represents a Feature
class Supportable
include Templatable
+ include DynamicAttributes
attr_accessor :supported
- def initialize(*custom_attributes)
- @custom_attributes = Hash[
- custom_attributes.map { |x| ["#{x}=".to_sym, nil] }
+ def initialize(*dynamic_attributes)
+ @dynamic_attributes = Hash[
+ dynamic_attributes.map { |x| ["#{x}=".to_sym, nil] }
]
@supported = false
end
-
- def method_missing(method, *args)
- if respond_to_missing?(method)
- @custom_attributes[method] = args[0]
- else
- super
- end
- end
-
- def respond_to_missing?(method, _include_private = false)
- @custom_attributes.key?(method)
- end
end
end
end
lib/scim/kit/dynamic_attributes.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+module Scim
+ module Kit
+ # Allows dynamic assignment of attributes.
+ module DynamicAttributes
+ def method_missing(method, *args)
+ return super unless respond_to_missing?(method)
+
+ @dynamic_attributes[method] = args[0]
+ end
+
+ def respond_to_missing?(method, _include_private = false)
+ @dynamic_attributes.key?(method) || super
+ end
+ end
+ end
+end
lib/scim/kit/version.rb
@@ -2,6 +2,6 @@
module Scim
module Kit
- VERSION = '0.1.0'
+ VERSION = '0.2.0'
end
end
lib/scim/kit.rb
@@ -3,6 +3,7 @@
require 'tilt'
require 'tilt/jbuilder'
+require 'scim/kit/dynamic_attributes'
require 'scim/kit/templatable'
require 'scim/kit/template'
require 'scim/kit/version'