Class: S3AssetsUploader::Config

Inherits:
Struct
  • Object
show all
Defined in:
lib/s3_assets_uploader/config.rb

Defined Under Namespace

Classes: ValidationError

Constant Summary collapse

DEFAULT_ASSETS_PATH =
'public/assets'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



10
11
12
13
# File 'lib/s3_assets_uploader/config.rb', line 10

def initialize
  self.assets_path = DEFAULT_ASSETS_PATH
  self.additional_paths = []
end

Instance Attribute Details

#additional_pathsObject

Returns the value of attribute additional_paths

Returns:

  • (Object)

    the current value of additional_paths



4
5
6
# File 'lib/s3_assets_uploader/config.rb', line 4

def additional_paths
  @additional_paths
end

#assets_pathObject

Returns the value of attribute assets_path

Returns:

  • (Object)

    the current value of assets_path



4
5
6
# File 'lib/s3_assets_uploader/config.rb', line 4

def assets_path
  @assets_path
end

#assets_prefixObject

Returns the value of attribute assets_prefix

Returns:

  • (Object)

    the current value of assets_prefix



4
5
6
# File 'lib/s3_assets_uploader/config.rb', line 4

def assets_prefix
  @assets_prefix
end

#bucketObject

Returns the value of attribute bucket

Returns:

  • (Object)

    the current value of bucket



4
5
6
# File 'lib/s3_assets_uploader/config.rb', line 4

def bucket
  @bucket
end

#s3_clientObject

Returns the value of attribute s3_client

Returns:

  • (Object)

    the current value of s3_client



4
5
6
# File 'lib/s3_assets_uploader/config.rb', line 4

def s3_client
  @s3_client
end

Instance Method Details

#public_pathObject



19
20
21
# File 'lib/s3_assets_uploader/config.rb', line 19

def public_path
  assets_path.parent
end

#validate!Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/s3_assets_uploader/config.rb', line 23

def validate!
  if bucket.nil?
    raise ValidationError.new('config.bucket must be set')
  end
  additional_paths.each do |path|
    assert_under_public_path!(path)
  end
  self.s3_client ||= create_default_client
  true
end