lib/rack/lti/config.rb in rack-lti-0.1.0 vs lib/rack/lti/config.rb in rack-lti-0.1.1
- old
+ new
@@ -33,11 +33,13 @@
def public?
self[:consumer_key].nil? && self[:consumer_secret].nil?
end
- def to_xml(options = {})
+ def to_xml(request, options = {})
+ options = options.merge(get_extensions(request))
+
# Stringify keys for IMS::LTI
config = self.merge(options).inject({}) do |h, v|
h[v[0].to_s] = v[1]
h
end
@@ -51,8 +53,19 @@
elsif self.has_key?(method)
self[method]
else
super
end
+ end
+
+ private
+
+ def get_extensions(request)
+ return {} unless self.key? :extensions
+ extensions = self[:extensions].inject({}) do |h, (k, v)|
+ h[k] = v.respond_to?(:call) ? v.call(request) : v
+ h
+ end
+ { extensions: extensions }
end
end
end