Coder Social home page Coder Social logo

Comments (3)

cimm avatar cimm commented on June 20, 2024

I tried this in JRuby with Celerity and there it works so it really seems related to the remote proxy object.

from culerity.

 avatar commented on June 20, 2024

I can totally verify this. It happens to any Celerity::ElementCollections object using one of Culerity's remote proxy calls that uses a block argument, such as 'each'. This means that despite the fact that Celerity::ElementCollections is Enumerable, none of the Enumerable methods which take blocks work (e.g., 'detect'). I speculate that the problem is in the 'block_to_string' method in RemoteObjectProxy.rb:
def block_to_string &block
result = block.call.to_s.strip
unless result.is_a?(String) && result[/^lambda\s*({|do).+(}|end)/xm]
result = "lambda { #{result} }"
end
result.gsub("\n", ";")
end

The line "result = block.call.to_s.strip" is the problem, I speculate. For instance, in the case of the 'each' method in the example above, 'each' has yet to be sent via the send_remote method to Celerity, so it hasn't had a chance to return a link. And when block.call is executed it expects, in this case, a link object to be present and that object will have a .inspect method. However, at this point in the call chain, the link in the block is unbound, so an error occurs. In my experience, it usually says that object nil does not have a particular method name.

from culerity.

 avatar commented on June 20, 2024

I have created a patch on my personal branch to show how this problem can be fixed.

https://github.com/chad-medi/culerity/commit/9e65312dd86e893ef86b90df39e4a2310f46a12a

The fix is pretty brutal, removing the possibility of explicitly passing a block to a remote call (of course, Ruby always allows you to pass blocks, but in this case, they are now ignored). The patch also transforms Culerity's RemoteObjectProxy to an Enumerable object, which means methods based on 'each' iteration now work. This solution is not ideal, since not all all objects returned by RemoteObjectProxy are collections that could be enumerated. A less 'hacky' patch would, I believe, require significant architectural changes to Culerity making it less of a proxy library.

from culerity.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.