Class: BettyResource::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/betty_resource/configuration.rb

Defined Under Namespace

Classes: InvalidError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Configuration

Returns a new instance of Configuration.



5
6
7
8
9
# File 'lib/betty_resource/configuration.rb', line 5

def initialize(args = {})
  args.each do |key, value|
    send("#{key}=", value) if [:host, :user, :password].include?(key.to_sym)
  end
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



13
14
15
# File 'lib/betty_resource/configuration.rb', line 13

def host
  @host
end

#passwordObject

Returns the value of attribute password.



13
14
15
# File 'lib/betty_resource/configuration.rb', line 13

def password
  @password
end

#userObject

Returns the value of attribute user.



13
14
15
# File 'lib/betty_resource/configuration.rb', line 13

def user
  @user
end

Instance Method Details

#validate!Object

Raises:



15
16
17
# File 'lib/betty_resource/configuration.rb', line 15

def validate!
  raise InvalidError if [:host, :user, :password].any? { |option| send(option).to_s.strip.empty? }
end