Class: Miasma::Models::Storage::Files

Inherits:
Types::Collection show all
Defined in:
lib/miasma/models/storage/files.rb

Overview

Abstract file collection

Instance Attribute Summary collapse

Attributes inherited from Types::Collection

#api

Instance Method Summary collapse

Methods inherited from Types::Collection

#all, #from_json, #get, #reload, #to_json

Methods included from Utils::Memoization

#_memo, #clear_memoizations!, #memoize, #unmemoize

Constructor Details

#initialize(bucket) ⇒ self

Create new instance

Parameters:

  • bucket (Bucket)

    parent bucket



17
18
19
20
# File 'lib/miasma/models/storage/files.rb', line 17

def initialize(bucket)
  @bucket = bucket
  super bucket.api
end

Instance Attribute Details

#bucketBucket (readonly)

Returns parent bucket.

Returns:



11
12
13
# File 'lib/miasma/models/storage/files.rb', line 11

def bucket
  @bucket
end

Instance Method Details

#build(args = {}) ⇒ File

Returns new unsaved instance.

Returns:

  • (File)

    new unsaved instance



32
33
34
35
36
37
38
39
# File 'lib/miasma/models/storage/files.rb', line 32

def build(args={})
  instance = self.model.new(bucket)
  args.each do |m_name, m_value|
    m_name = "#{m_name}="
    instance.send(m_name, m_value)
  end
  instance
end

#filter(options = {}) ⇒ Array<File>

Return files matching given filter

Parameters:

  • options (Hash) (defaults to: {})

    filter options

Options Hash (options):

  • :prefix (String)

    key prefix

Returns:

Raises:

  • (NotImplementedError)


27
28
29
# File 'lib/miasma/models/storage/files.rb', line 27

def filter(options={})
  raise NotImplementedError
end

#modelFile

Returns collection item class.

Returns:

  • (File)

    collection item class



42
43
44
# File 'lib/miasma/models/storage/files.rb', line 42

def model
  File
end