Class: Mediaflux::RootCollectionAsset
- Inherits:
-
Object
- Object
- Mediaflux::RootCollectionAsset
- Defined in:
- app/models/mediaflux/root_collection_asset.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#parent_collection ⇒ Object
readonly
Returns the value of attribute parent_collection.
-
#parent_ns ⇒ Object
readonly
Returns the value of attribute parent_ns.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#root_ns ⇒ Object
readonly
Returns the value of attribute root_ns.
Instance Method Summary collapse
-
#create ⇒ Object
Creates the root collection asset (e.g. ‘tigerdata`) Notice that this collection asset lives under a root namespace (e.g. `/princeton` in production or `td-demo-001` in development).
-
#initialize(session_token:, root_ns:, parent_collection:) ⇒ RootCollectionAsset
constructor
In the context of this class:.
Constructor Details
#initialize(session_token:, root_ns:, parent_collection:) ⇒ RootCollectionAsset
In the context of this class:
root_ns: The root namespace (e.g. /princeton) for everything in Mediaflux.
parent_collection: The collection that is the parent to all other collections (e.g. tigerdata)
and this collection lives under root_ns (e.g. /princeton/tigerdata)
parent_ns: The namespace that is the parent to all namespaces for projects and
and this namespace lives under root_ns (e.g. /princeton/tigerdataNS)
Notice that parent_ns is a sibling to parent_collection (i.e. they both live under root_ns)
During development the root_ns is typicall “/td-demo-001” and parent_collection and parent_ns live under it (e.g. /td-demo-001/tigerdata and /td-demo-001/tigerdataNS).
When running the test suite root_ns is typically “/td-test-001/test” and the parent_collection and parent_ns live under it (e.g. /td-test-001/test/tigerdata and /td-test-001/test/tigerdataNS).
24 25 26 27 28 29 30 31 |
# File 'app/models/mediaflux/root_collection_asset.rb', line 24 def initialize(session_token:, root_ns:, parent_collection:) @session_token = session_token @root_ns = root_ns || Rails.configuration.mediaflux["api_root_collection_namespace"] # /princeton or /td-demo-001 @parent_collection = parent_collection || Rails.configuration.mediaflux["api_root_collection_name"] # tigerdata @parent_ns = Rails.configuration.mediaflux["api_root_ns"] # /td-demo-001/tigerdataNS @path = Pathname.new(@root_ns).join(@parent_collection).to_s @error = nil end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
4 5 6 |
# File 'app/models/mediaflux/root_collection_asset.rb', line 4 def error @error end |
#parent_collection ⇒ Object (readonly)
Returns the value of attribute parent_collection.
4 5 6 |
# File 'app/models/mediaflux/root_collection_asset.rb', line 4 def parent_collection @parent_collection end |
#parent_ns ⇒ Object (readonly)
Returns the value of attribute parent_ns.
4 5 6 |
# File 'app/models/mediaflux/root_collection_asset.rb', line 4 def parent_ns @parent_ns end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
4 5 6 |
# File 'app/models/mediaflux/root_collection_asset.rb', line 4 def path @path end |
#root_ns ⇒ Object (readonly)
Returns the value of attribute root_ns.
4 5 6 |
# File 'app/models/mediaflux/root_collection_asset.rb', line 4 def root_ns @root_ns end |
Instance Method Details
#create ⇒ Object
Creates the root collection asset (e.g. ‘tigerdata`) Notice that this collection asset lives under a root namespace (e.g. `/princeton` in production or `td-demo-001` in development)
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/models/mediaflux/root_collection_asset.rb', line 35 def create check_root = Mediaflux::AssetExistRequest.new(session_token: @session_token, path: @path) return true if check_root.exist? if create_root_namespace create_request = Mediaflux::CollectionAssetCreateRootRequest.new(session_token: @session_token, namespace: @root_ns, name: @parent_collection) create_request.resolve @error = create_request.response_error return false if @error.present? create_parent_ns else false end end |