Sha256: 152d2a96075a2c1eef16d97d644f6613ae9f7551f6421d7b786f00f9d46b9997

Contents?: true

Size: 524 Bytes

Versions: 17

Compression:

Stored size: 524 Bytes

Contents

class Module
    def class_alias_method(to, from)
      # https://tieba.baidu.com/p/5535445605?red_tag=0735709674  贴吧大神给出的方案
      # 类方法可以看做singleton class(单例类)的实例方法,下面两个方法都可以,上面这个方式也适用于早期的ruby版本
      (class << self;self;end).send(:alias_method, to, from)
      # self.singleton_class.send(:alias_method, to, from)
    end

    def class_attr_accessor(symbol)
        self.class.send(:attr_accessor, symbol)
    end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
cocoapods-jxedt-0.0.21 lib/cocoapods-jxedt/tool.rb
cocoapods-jxedt-0.0.20 lib/cocoapods-jxedt/tool.rb
cocoapods-jxedt-0.0.19 lib/cocoapods-jxedt/tool.rb
cocoapods-jxedt-0.0.18 lib/cocoapods-jxedt/tool.rb
cocoapods-jxedt-0.0.17 lib/cocoapods-jxedt/tool.rb
cocoapods-jxedt-0.0.16 lib/cocoapods-jxedt/tool.rb
cocoapods-jxedt-0.0.15 lib/cocoapods-jxedt/tool.rb
cocoapods-util-0.2.2 lib/cocoapods-util/tool.rb
cocoapods-jxedt-0.0.14 lib/cocoapods-jxedt/tool.rb
cocoapods-jxedt-0.0.13 lib/cocoapods-jxedt/tool.rb
cocoapods-jxedt-0.0.12 lib/cocoapods-jxedt/tool.rb
cocoapods-jxedt-0.0.10 lib/cocoapods-jxedt/tool.rb
cocoapods-jxedt-0.0.9 lib/cocoapods-jxedt/tool.rb
cocoapods-util-0.2.1 lib/cocoapods-util/tool.rb
cocoapods-util-0.2.0 lib/cocoapods-util/tool.rb
cocoapods-util-0.0.16 lib/cocoapods-util/tool.rb
cocoapods-util-0.0.15 lib/cocoapods-util/tool.rb