Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/mharris_ext/object.rb,
lib/mharris_ext/methods.rb,
lib/mharris_ext/accessor.rb
Instance Method Summary collapse
- #attr_accessor_nn(*args) ⇒ Object
- #attr_accessor_nn_one(sym) ⇒ Object
- #local_methods ⇒ Object
- #tap {|_self| ... } ⇒ Object
Instance Method Details
#attr_accessor_nn(*args) ⇒ Object
10 11 12 |
# File 'lib/mharris_ext/accessor.rb', line 10 def attr_accessor_nn(*args) args.flatten.each { |x| attr_accessor_nn_one(x) } end |
#attr_accessor_nn_one(sym) ⇒ Object
2 3 4 5 6 7 8 9 |
# File 'lib/mharris_ext/accessor.rb', line 2 def attr_accessor_nn_one(sym) define_method(sym) do res = instance_variable_get("@#{sym}") raise "method #{sym} cannot return nil value" unless res res end attr_writer(sym) end |
#local_methods ⇒ Object
2 3 4 5 |
# File 'lib/mharris_ext/methods.rb', line 2 def local_methods res = methods - 7.methods - "".methods res.sort_by { |x| x.to_s } end |
#tap {|_self| ... } ⇒ Object
2 3 4 5 |
# File 'lib/mharris_ext/object.rb', line 2 def tap yield(self) self end |