Module: Tori

Defined in:
lib/tori.rb,
lib/tori/file.rb,
lib/tori/config.rb,
lib/tori/define.rb,
lib/tori/context.rb,
lib/tori/version.rb,
lib/tori/backend/s3.rb,
lib/tori/backend/chain.rb,
lib/tori/backend/filesystem.rb

Defined Under Namespace

Modules: Backend, Define Classes: Config, Context, File

Constant Summary collapse

VERSION =
"0.8.0"

Class Method Summary collapse

Class Method Details

.configObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/tori.rb', line 7

def config
  @config ||= Config.new.tap do |config|
    # Default backend config
    #   You can change setting any time.
    #   Recommend to create config/initializer/tori.rb for setting.

    # Configure for file store backend instance.
    config.backend = Tori::Backend::FileSystem.new(Pathname("tmp/tori"))

    # You can also use S3 backend.
    # It take 'aws-sdk-core' gem.
    # S3 example
    #   require 'tori/backend/s3'
    #   config.backend = Tori::Backend::S3.new(bucket: 'tori_bucket')

    # Filename hashing method
    #   It's call when decide filename hash.
    config.filename_callback do |model|
      Digest::SHA1.hexdigest "#{model.class.name}/#{model.id}"
    end
  end
end