Class: ConfigOMat::Profile

Inherits:
ConfigItem show all
Defined in:
lib/config_o_mat/shared/types.rb

Instance Attribute Summary collapse

Attributes inherited from ConfigItem

#errors

Instance Method Summary collapse

Methods inherited from ConfigItem

#==, #error, #errors?, #validate!

Constructor Details

#initialize(opts) ⇒ Profile

Returns a new instance of Profile.



171
172
173
174
175
176
# File 'lib/config_o_mat/shared/types.rb', line 171

def initialize(opts)
  @application = opts[:application]
  @environment = opts[:environment]
  @profile = opts[:profile]
  @s3_fallback = opts[:s3_fallback]
end

Instance Attribute Details

#applicationObject (readonly)

Returns the value of attribute application.



169
170
171
# File 'lib/config_o_mat/shared/types.rb', line 169

def application
  @application
end

#environmentObject (readonly)

Returns the value of attribute environment.



169
170
171
# File 'lib/config_o_mat/shared/types.rb', line 169

def environment
  @environment
end

#profileObject (readonly)

Returns the value of attribute profile.



169
170
171
# File 'lib/config_o_mat/shared/types.rb', line 169

def profile
  @profile
end

#s3_fallbackObject (readonly)

Returns the value of attribute s3_fallback.



169
170
171
# File 'lib/config_o_mat/shared/types.rb', line 169

def s3_fallback
  @s3_fallback
end

Instance Method Details

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


195
196
197
198
199
200
201
202
203
204
# File 'lib/config_o_mat/shared/types.rb', line 195

def eql?(other)
  return false if !super(other)
  if other.application != application ||
     other.environment != environment ||
     other.profile != profile ||
     other.s3_fallback != s3_fallback
    return false
  end
  true
end

#hashObject



191
192
193
# File 'lib/config_o_mat/shared/types.rb', line 191

def hash
  application.hash ^ environment.hash ^ profile.hash ^ s3_fallback.hash
end

#validateObject



178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/config_o_mat/shared/types.rb', line 178

def validate
  error :application, PRESENCE_ERROR_MSG if @application.nil? || @application.empty?
  error :environment, PRESENCE_ERROR_MSG if @environment.nil? || @environment.empty?
  error :profile, PRESENCE_ERROR_MSG if @profile.nil? || @profile.empty?
  if !@s3_fallback.nil?
    if @s3_fallback.kind_of?(String)
      error :s3_fallback, 'must be non-empty' if @s3_fallback.empty?
    else
      error :s3_fallback, 'must be a string'
    end
  end
end