Loading...
Loading...
Compare original and translation side by side
lib/gemname.rbundefinedlib/gemname.rbundefinedundefinedundefinedundefinedundefined mod = Module.new
mod.module_eval do
define_method :some_method do
# implementation
end unless method_defined?(:some_method)
end
include mod
class_eval do
cattr_reader :gemname_options, instance_reader: false
class_variable_set :@@gemname_options, options.dup
end
endundefined mod = Module.new
mod.module_eval do
define_method :some_method do
# 实现逻辑
end unless method_defined?(:some_method)
end
include mod
class_eval do
cattr_reader :gemname_options, instance_reader: false
class_variable_set :@@gemname_options, options.dup
end
endundefinedActiveSupport.on_loadundefinedActiveSupport.on_loadundefinedundefinedundefinedclass << selfattr_accessormodule GemName
class << self
attr_accessor :timeout, :logger
attr_writer :master_key
end
def self.master_key
@master_key ||= ENV["GEMNAME_MASTER_KEY"]
end
self.timeout = 10
self.logger = nil
endclass << selfattr_accessormodule GemName
class << self
attr_accessor :timeout, :logger
attr_writer :master_key
end
def self.master_key
@master_key ||= ENV["GEMNAME_MASTER_KEY"]
end
self.timeout = 10
self.logger = nil
endmodule GemName
class Error < StandardError; end
class ConfigError < Error; end
class ValidationError < Error; end
endmodule GemName
class Error < StandardError; end
class ConfigError < Error; end
class ValidationError < Error; end
endundefinedundefinedundefinedundefinedundefinedundefinedGem::Specification.new do |spec|
spec.name = "gemname"
spec.version = GemName::VERSION
spec.required_ruby_version = ">= 3.1"
spec.files = Dir["*.{md,txt}", "{lib}/**/*"]
spec.require_path = "lib"
# NO add_dependency lines - dev deps go in Gemfile
endGem::Specification.new do |spec|
spec.name = "gemname"
spec.version = GemName::VERSION
spec.required_ruby_version = ">= 3.1"
spec.files = Dir["*.{md,txt}", "{lib}/**/*"]
spec.require_path = "lib"
# 不要添加add_dependency行 - 开发依赖放在Gemfile中
endmethod_missingdefine_method@@class_variablesclass << selfmethod_missingdefine_method@@类变量class << self