Giter VIP home page Giter VIP logo

Comments (4)

enebo avatar enebo commented on July 22, 2024

You comment is right in that if you call attr_accessor and then def the same methods they will override. The opposite is also true however. If you attr_accessor after you have defined your methods then attr_accessor versions of the methods will replace your existing ones.

Here is an idea. We could stop using @ivar for storage and only use gett/setter methods (and if none are defined then define them)? As it stands right now attribute behavior is a bit destructive in that it assumes it can just make getter and setter methods. I am going to ask Jay to comment since he made the original impl of attributes.

from jmx.

enebo avatar enebo commented on July 22, 2024

I changed the behavior of this in 5c0295f and hopefully all parties will be happy. There are new optional fields for the *_attribute methods. The extra arguments exist for specifying the name of the method to send to if provided:

r_attribute :explicit_reader, :int, "Sample int with writer", :my_reader
w_attribute :explicit_writer, :int, "Sample int with writer", :my_writer
rw_attribute :explicit_both, :int, "Sample int with writer", :my_read, :my_write

def my_reader
    @domain_object.real_value
end

This also satisfies a larger requirement that the Dynamic MBean does not need to be the real source of data. Define your own method which then asks the real source of data for your attribute value. Thanks for filing this. It made me step back a bit on this feature. Also let me know if this works for you and then I will push 0.6.

Jay, the only real change between what we had before and what we have now if you do not provide explicit read/write methods is that we will not override via attr_reader, etc.. if
there is already a method of the same name.

from jmx.

hooligan495 avatar hooligan495 commented on July 22, 2024

At first glance it looks good to me.. I'll spend more time reviewing over the next day or so... work's been crazy lately :P

from jmx.

bpardee avatar bpardee commented on July 22, 2024

It looks good to me too. Thanks!

from jmx.

Related Issues (9)

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.