Sha256: 3c968f697e74e9ce67bbba90a098a09f7c090b35428480fa091b960631280a5b
Contents?: true
Size: 915 Bytes
Versions: 12
Compression:
Stored size: 915 Bytes
Contents
class Evil::Client # # Resolves scope/operation-specific middleware from schema for some settings # # New middleware are added to previously defined ones. # To reset all predefined middleware, set value to nil. # # @private # class Resolver::Middleware < Resolver private def initialize(schema, settings) super schema, settings, :middleware end def __call__ super do __blocks__.map.with_object([]) do |block, obj| list = __normalize__ instance_exec(&block) obj.replace([]) unless list obj.concat Array(list) end.reverse end end def __normalize__(value) case value when nil then nil when Class then value when Array then value.flatten.compact.map { |val| __normalize__(val) } else raise __definition_error__("#{value} is neither class nor array") end end end end
Version data entries
12 entries across 12 versions & 1 rubygems