#!/bin/ruby
module Pipline
class << self
attr_accessor :seg_column_name
end
self.seg_column_name = 'X'
end
class A
include Pipline
self.seg_column_name ='a'
end
class B
include Pipline
self.seg_column_name ='b'
end
我期望是可以让类 A 和 B 都可以设置自己的 column_name, Pipline.seg_column_name => 'X' A.seg_column_name =>'a' B.seg_column_name =>'b'
但实际是
Traceback (most recent call last):
5: from /Users/zhouqiang/.rvm/rubies/ruby-2.7.2/bin/irb:23:in <main>'
4: from /Users/zhouqiang/.rvm/rubies/ruby-2.7.2/bin/irb:23:in
load'
3: from /Users/zhouqiang/.rvm/rubies/ruby-2.7.2/lib/ruby/gems/2.7.0/gems/irb-1.2.6/exe/irb:11:in <top (required)>'
2: from (irb):9
1: from (irb):11:in
class:A'
NoMethodError (undefined method `seg_column_name=' for A:Class)
求教,如果为了实现我的这个目标,应该怎么改?