Module: SPQR::ManageableClassMixins
- Defined in:
- lib/spqr/manageable.rb
Instance Method Summary collapse
-
#expose(name, description = nil, options = nil, &blk) ⇒ Object
Exposes a method to QMF.
- #log ⇒ Object
- #log=(logger) ⇒ Object
- #qmf_class_name(nm) ⇒ Object
- #qmf_description(d) ⇒ Object
- #qmf_options(opts) ⇒ Object
- #qmf_package_name(nm) ⇒ Object
- #qmf_property(name, kind, options = nil) ⇒ Object
- #qmf_statistic(name, kind, options = nil) ⇒ Object
- #spqr_meta ⇒ Object
Instance Method Details
#expose(name, description = nil, options = nil, &blk) ⇒ Object
Exposes a method to QMF
140 141 142 |
# File 'lib/spqr/manageable.rb', line 140 def expose(name, description=nil, =nil, &blk) .declare_method(name, description, , blk) end |
#log ⇒ Object
135 136 137 |
# File 'lib/spqr/manageable.rb', line 135 def log @spqr_log || ::SPQR::Sink.new end |
#log=(logger) ⇒ Object
131 132 133 |
# File 'lib/spqr/manageable.rb', line 131 def log=(logger) @spqr_log = logger end |
#qmf_class_name(nm) ⇒ Object
148 149 150 |
# File 'lib/spqr/manageable.rb', line 148 def qmf_class_name(nm) .classname = nm end |
#qmf_description(d) ⇒ Object
152 153 154 |
# File 'lib/spqr/manageable.rb', line 152 def qmf_description(d) .description = d end |
#qmf_options(opts) ⇒ Object
156 157 158 |
# File 'lib/spqr/manageable.rb', line 156 def (opts) . = opts.dup end |
#qmf_package_name(nm) ⇒ Object
144 145 146 |
# File 'lib/spqr/manageable.rb', line 144 def qmf_package_name(nm) .package = nm end |
#qmf_property(name, kind, options = nil) ⇒ Object
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/spqr/manageable.rb', line 176 def qmf_property(name, kind, =nil) .declare_property(name, kind, ) # add a property accessor to instances of other self.class_eval do # XXX: should cons up a "safe_attr_accessor" method that works like this: attr_reader name.to_sym unless instance_methods.include? "#{name}" attr_writer name.to_sym unless instance_methods.include? "#{name}=" end if and [:index] # if this is an index property, add a find-by method if one # does not already exist spqr_define_index_find(name) end end |
#qmf_statistic(name, kind, options = nil) ⇒ Object
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/spqr/manageable.rb', line 160 def qmf_statistic(name, kind, =nil) .declare_statistic(name, kind, ) self.class_eval do # XXX: are we only interested in declaring a reader for # statistics? Doesn't it really makes more sense for the managed # class to declare a method with the same name as the # statistic so we aren't declaring anything at all here? # XXX: should cons up a "safe_attr_reader" method that works # like this: attr_reader name.to_sym unless instance_methods.include? "#{name}" attr_writer name.to_sym unless instance_methods.include? "#{name}=" end end |
#spqr_meta ⇒ Object
127 128 129 |
# File 'lib/spqr/manageable.rb', line 127 def ||= ::SPQR::ManageableMeta.new end |