Module: Skywalker::Acceptable

Defined in:
lib/skywalker/acceptable.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object

Creates an ‘_args` accessor on inclusion.

Since:

  • 2.0.0



9
10
11
# File 'lib/skywalker/acceptable.rb', line 9

def self.included(klass)
  klass.send(:attr_accessor, :_args)
end

Instance Method Details

#initialize(**args) {|_self| ... } ⇒ Object

Instantiates an object, setting all kwargs as accessors, and yields self to any block given.

Yields:

  • (_self)

Yield Parameters:

Since:

  • 2.0.0



20
21
22
23
24
25
26
27
28
# File 'lib/skywalker/acceptable.rb', line 20

def initialize(**args)
  self._args = args
  self._args.freeze

  validate_arguments!
  parse_arguments

  yield self if block_given?
end