Git Product home page Git Product logo

Comments (6)

gorn avatar gorn commented on August 10, 2024

I agree with you, that this is to avoid. Generally I use monkey patching in initial phases of development, because it nicely allows to get on the track (I like this on ruby). But apparently this project has reached next level, so it is time to refactor this out. I will look at refinements.

from rspreadsheet.

gorn avatar gorn commented on August 10, 2024

Closing this issue in release v0.2.14 - please have a look. I use refinements for newer versions of ruby (from 2.1, because the keyword "using" fails in ruby 2.0). I leave monkey patching for older ruby, for now, if you have better idea how to do it, let me know.

from rspreadsheet.

zekefast avatar zekefast commented on August 10, 2024

@gorn Thanks! I shall take a look at it on the weekend.

from rspreadsheet.

zekefast avatar zekefast commented on August 10, 2024

@gorn I saw usage of refinements, but do not understand where you fallback to monkey patching for Ruby versions which does not support them. So, I can not make reasonable opinion on it. But you can require different files based on ruby version or use forwarding to forward to the same methods from refinements and from monkey patching. That is as a workaround, but in general best approach would be to rewrite code to avoid need in monkey patching at all even with refinements it is still monkey patching...

from rspreadsheet.

gorn avatar gorn commented on August 10, 2024

I put all the "optional" code in https://github.com/gorn/rspreadsheet/blob/master/lib/helpers/class_extensions.rb ... I guess that it will fade away onece ruby 1.9 gois to oblivion.

I understand your point, but I think, that especially in case of LibXML::XML::Node it is more logical usage of ruby open classes than monkeypatching. The thing is, that on many places in code I work with LibXML::XML::Node objects returned by methods of LibXML::XML::Node class (like parent) and I can not imagine the decorator approach, which would enable to add my own methods, yet seemlesly get out of the way if someone else would like to reuse LibXML::XML::Node objects returned by my code. It would mean to dump decorator object and recreate everytime i pass such a thing like a parameter, which for is much uglier. However if you have any insigt at this I will be glad to hear it.

from rspreadsheet.

gorn avatar gorn commented on August 10, 2024

Nice article about decorators
https://robots.thoughtbot.com/evaluating-alternative-decorator-implementations-in

from rspreadsheet.

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.