Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/freighthopper/is_one_of.rb,
lib/freighthopper/soft_send.rb,
lib/freighthopper/eigenclass.rb,
lib/freighthopper/or_if_blank.rb,
lib/freighthopper/eval_with_options.rb
Instance Method Summary collapse
- #define_eigenmethod(method_name, &blk) ⇒ Object
- #eigenclass ⇒ Object
- #eigenmethod(method_name) ⇒ Object
- #eval_with_options(*args, &blk) ⇒ Object
- #is_one_of?(*args) ⇒ Boolean
- #or_if_blank(val = nil) ⇒ Object
- #soft_send(method, *args) ⇒ Object
Instance Method Details
#define_eigenmethod(method_name, &blk) ⇒ Object
8 9 10 |
# File 'lib/freighthopper/eigenclass.rb', line 8 def define_eigenmethod(method_name, &blk) eigenclass.send :define_method, method_name, &blk end |
#eigenclass ⇒ Object
2 3 4 5 6 |
# File 'lib/freighthopper/eigenclass.rb', line 2 def eigenclass class << self self end end |
#eigenmethod(method_name) ⇒ Object
12 13 14 |
# File 'lib/freighthopper/eigenclass.rb', line 12 def eigenmethod(method_name) eigenclass.instance_method(method_name) end |
#eval_with_options(*args, &blk) ⇒ Object
2 3 4 5 6 |
# File 'lib/freighthopper/eval_with_options.rb', line 2 def (*args, &blk) *args do |map| map.instance_eval(&blk) end end |
#is_one_of?(*args) ⇒ Boolean
2 3 4 |
# File 'lib/freighthopper/is_one_of.rb', line 2 def is_one_of?(*args) args.flatten.any?{|arg| arg === self } end |
#or_if_blank(val = nil) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/freighthopper/or_if_blank.rb', line 4 def or_if_blank(val = nil) if soft_send :blank? val || (block_given? ? yield : nil) else self end end |
#soft_send(method, *args) ⇒ Object
2 3 4 |
# File 'lib/freighthopper/soft_send.rb', line 2 def soft_send(method, *args) send method, *args if respond_to? method end |