Extending a ruby gem in Rails

前端 未结 2 1031
面向向阳花
面向向阳花 2021-02-09 20:23

Let\'s say I have a Rails app that gets most of it\'s functionality from a gem (for instance, a CMS).

If I now need to add some customisation (for instance, add a proper

2条回答
  •  一个人的身影
    2021-02-09 20:48

    Ruby allows you to extend classes in runtime, so you can often hack in to a library without touching the source code. Otherwise I would suggest that you download the gem, create some hooks in the library and submit that back as a patch.

    Update:

    Note that these customisations are application specific

    Yes. What I meant was to modify the generic api in a way, such that it is possible to customise per application. For example, by allowing the user to pass a block to certain methods etc.

提交回复
热议问题