Module: Zoidberg::Shell
- Included in:
- Pool, Registry, Supervisor
- Defined in:
- lib/zoidberg/shell.rb
Overview
Provides a wrapping around a real instance. Including this module within a class will enable magic.
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Class Method Summary collapse
-
.included(klass) ⇒ Object
Inject Shell magic into given class when included.
Class Method Details
.included(klass) ⇒ Object
Inject Shell magic into given class when included
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
# File 'lib/zoidberg/shell.rb', line 312 def self.included(klass) unless(klass.ancestors.include?(Zoidberg::Shell::InstanceMethods)) klass.class_eval do class << self alias_method :unshelled_new, :new # Set an option or multiple options # # @return [Array<Symbol>] def option(*args) @option ||= [] unless(args.empty?) @option += args @option.map!(&:to_sym).uniq! end @option end # Check if option is available # # @param arg [Symbol] # @return [TrueClass, FalseClass] def option?(arg) option.include?(arg.to_sym) end end include InstanceMethods extend ClassMethods include Bogo::Memoization end end unless(klass.include?(SoftShell) || klass.include?(HardShell)) klass.class_eval do include Zoidberg.default_shell end end end |