Class: Schron::Datastore::Mongo::Metadata
- Inherits:
-
Schron::Datastore::Metadata
- Object
- Schron::Datastore::Metadata
- Schron::Datastore::Mongo::Metadata
- 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
-
#fetch_metadata ⇒ Array
An array of hashes, each with the following keys: * kind * field * type.
-
#initialize(db, collection_name = :schron_metadata) ⇒ Metadata
constructor
A new instance of Metadata.
- #insert_metadata(kind, field, type) ⇒ Object
- #natively_supported?(value) ⇒ Boolean
- #recursive? ⇒ Boolean
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_metadata ⇒ Array
Returns 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
31 32 33 |
# File 'lib/schron/datastore/mongo/metadata.rb', line 31 def natively_supported?(value) NATIVELY_SUPPORTED.include?(value.class) end |
#recursive? ⇒ Boolean
27 28 29 |
# File 'lib/schron/datastore/mongo/metadata.rb', line 27 def recursive? true end |