Skip to content

Instantly share code, notes, and snippets.

@elrayle
Created August 19, 2021 19:39
Show Gist options
  • Save elrayle/6732881012111fe2c3839b3034afaf24 to your computer and use it in GitHub Desktop.
Save elrayle/6732881012111fe2c3839b3034afaf24 to your computer and use it in GitHub Desktop.
Allow AF or Valkyrie everywhere
def method_missing(method_name, *args, &block)
resource = self.valkyrie_resource
super unless resource.respond_to? method_name
resource.public_send(method_name, *arguments, &block)
end
def method_missing(method_name, *args, &block)
af_object = Wings::ActiveFedoraConverter.new(resource: self).convert
super unless af_object.respond_to? method_name
af_object.public_send(method_name, *arguments, &block)
end
@elrayle
Copy link
Author

elrayle commented Aug 19, 2021

If we have the class, we could avoid creating the instance until we know it is needed by using...

def method_missing(method_name, *args, &block)
  resource_class = # get from self somehow
  super unless resource_class.method_defined? method_name
  resource = self.valkyrie_resource
  resource.public_send(method_name, *arguments, &block)
end

and

def method_missing(method_name, *args, &block)
  af_class = # get from self somehow
  super unless af_class.method_defined? method_name
  af_object = Wings::ActiveFedoraConverter.new(resource: self).convert
  af_object.public_send(method_name, *arguments, &block)
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment