Comments (4)
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.
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.
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.
It looks good to me too. Thanks!
from jmx.
Related Issues (9)
- setAttributes is internally using invoke on MBean HOT 5
- JMX::MBeans.parent_for unreliable in Jruby 9000 HOT 5
- Gem doesn't allow specifying a service url
- MBeans created by another MBean don't have attributes/operations show up HOT 2
- Extended MBeans don't have parents operations/attributes. HOT 2
- JMX::MBeanProxy#method_missing is broken HOT 3
- MBeanServer#[] crashes in const_defined? when MBean class name contains $ HOT 5
- The url in the gemspec points to the old repo location (enebo/jmx) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jmx.