Module: HyperStore::StateWrapper::ArgumentValidator

Included in:
HyperStore::StateWrapper
Defined in:
lib/hyper-store/state_wrapper/argument_validator.rb

Defined Under Namespace

Classes: InvalidOptionError

Instance Method Summary collapse

Instance Method Details

#validate_args!(klass, *args, &block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/hyper-store/state_wrapper/argument_validator.rb', line 6

def validate_args!(klass, *args, &block)
  name, initial_value, opts = parse_arguments(*args, &block)

  opts[:scope]     ||= default_scope(klass)
  opts[:initializer] = validate_initializer(initial_value, klass, opts)
  opts[:block]       = block if block

  if opts[:reader]
    opts[:reader] = opts[:reader] == true ? name : opts[:reader]
  end

  [name, opts]
end