Class: Schron::Datastore::Mongo::Metadata

Inherits:
Schron::Datastore::Metadata
  • Object
show all
Defined in:
lib/schron/datastore/mongo/metadata.rb

Constant Summary collapse

NATIVELY_SUPPORTED =
[
  String,
  Integer,
  Fixnum,
  Float,
  Array,
  Regexp,
  TrueClass,
  FalseClass,
  Time,
  Hash,
  Symbol,
  BSON::Binary
]

Instance Method Summary collapse

Constructor Details

#initialize(db, collection_name = :schron_metadata) ⇒ Metadata

Returns a new instance of Metadata.



23
24
25
# File 'lib/schron/datastore/mongo/metadata.rb', line 23

def initialize(db, collection_name=:schron_metadata)
  @collection = db[collection_name]
end

Instance Method Details

#fetch_metadataArray

Returns an array of hashes, each with the following keys:

  • kind

  • field

  • type.

Returns:

  • (Array)

    an array of hashes, each with the following keys:

    • kind

    • field

    • type



39
40
41
# File 'lib/schron/datastore/mongo/metadata.rb', line 39

def 
  @collection.find
end

#insert_metadata(kind, field, type) ⇒ Object



43
44
45
# File 'lib/schron/datastore/mongo/metadata.rb', line 43

def (kind, field, type)
  @collection.insert(kind: kind, field: field, type: type)
end

#natively_supported?(value) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/schron/datastore/mongo/metadata.rb', line 31

def natively_supported?(value)
  NATIVELY_SUPPORTED.include?(value.class)
end

#recursive?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/schron/datastore/mongo/metadata.rb', line 27

def recursive?
  true
end