Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/card/core_ext.rb
Instance Method Summary collapse
-
#deep_clone ⇒ Object
FIXME: move this, mixin, don’t extend Object.
- #send_if(method, *args, &_block) ⇒ Object
- #send_unless(method, *args, &_block) ⇒ Object
- #to_name ⇒ Object
- #to_viewname ⇒ Object
Instance Method Details
#deep_clone ⇒ Object
FIXME: move this, mixin, don’t extend Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/card/core_ext.rb', line 3 def deep_clone case self when Fixnum, Bignum, Float, NilClass, FalseClass, TrueClass, Symbol klone = self when Hash klone = clone each { |k, v| klone[k] = v.deep_clone } when Array klone = clone klone.clear each { |v| klone << v.deep_clone } else klone = clone end klone.instance_variables.each do |v| klone.instance_variable_set(v, klone.instance_variable_get(v).deep_clone) end klone end |
#send_if(method, *args, &_block) ⇒ Object
28 29 30 |
# File 'lib/card/core_ext.rb', line 28 def send_if method, *args, &_block (block_given? ? yield : self) && send(method, *args) end |
#send_unless(method, *args, &_block) ⇒ Object
24 25 26 |
# File 'lib/card/core_ext.rb', line 24 def send_unless method, *args, &_block (block_given? ? yield : self) || send(method, *args) end |