Class: Object

Inherits:
BasicObject
Defined in:
lib/keystone/core_ext/blank.rb,
lib/keystone/core_ext/object.rb

Instance Method Summary collapse

Instance Method Details

#blank?Boolean

copy from activesupport

Returns:

  • (Boolean)


4
5
6
# File 'lib/keystone/core_ext/blank.rb', line 4

def blank?
  respond_to?(:empty?) ? empty? : !self
end

#class_def(name, &blk) ⇒ Object



21
22
23
# File 'lib/keystone/core_ext/object.rb', line 21

def class_def(name, &blk)
  class_eval { define_method name, &blk }
end

#meta_def(name, &blk) ⇒ Object



16
17
18
# File 'lib/keystone/core_ext/object.rb', line 16

def meta_def(name, &blk)
 meta_eval { define_method name, &blk }
end

#meta_eval(&blk) ⇒ Object



11
12
13
# File 'lib/keystone/core_ext/object.rb', line 11

def meta_eval(&blk)
  metaclass.instance_eval(&blk)
end

#metaclassObject



4
5
6
7
8
# File 'lib/keystone/core_ext/object.rb', line 4

def metaclass
  class << self
    self
  end
end

#tappObject

1.8.7 エミュレート TODO version 指定 def tap

yield(self)
self

end



32
33
34
# File 'lib/keystone/core_ext/object.rb', line 32

def tapp
  self.tap{|obj| p obj}
end