Class: AssetDB::Group
- Inherits:
-
Object
- Object
- AssetDB::Group
- Defined in:
- lib/asset_db/group.rb
Constant Summary collapse
- FOLDER_DEFAULT =
:__default
Instance Attribute Summary collapse
-
#database ⇒ Object
readonly
Returns the value of attribute database.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #folder_segment ⇒ Object
- #folder_spec ⇒ Object
-
#initialize(database, id, folder: FOLDER_DEFAULT) ⇒ Group
constructor
A new instance of Group.
-
#package(id, folder: FOLDER_DEFAULT) {|pkg| ... } ⇒ Object
DSL – fetch or create.
- #package_ids ⇒ Object
- #packages ⇒ Object
Constructor Details
#initialize(database, id, folder: FOLDER_DEFAULT) ⇒ Group
Returns a new instance of Group.
9 10 11 12 13 14 15 |
# File 'lib/asset_db/group.rb', line 9 def initialize(database, id, folder: FOLDER_DEFAULT) database.validate_identifier!(id) @database = database @id = id.to_s @folder = folder.equal?(FOLDER_DEFAULT) ? FOLDER_DEFAULT : folder @packages_hash = {} # {id ⇒ Package} end |
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
7 8 9 |
# File 'lib/asset_db/group.rb', line 7 def database @database end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/asset_db/group.rb', line 7 def id @id end |
Instance Method Details
#folder_segment ⇒ Object
34 35 36 37 38 |
# File 'lib/asset_db/group.rb', line 34 def folder_segment return id if @folder.equal?(FOLDER_DEFAULT) return nil if !@folder || @folder == '' || @folder == false @folder.to_s end |
#folder_spec ⇒ Object
30 31 32 |
# File 'lib/asset_db/group.rb', line 30 def folder_spec @folder end |
#package(id, folder: FOLDER_DEFAULT) {|pkg| ... } ⇒ Object
DSL – fetch or create.
18 19 20 21 22 |
# File 'lib/asset_db/group.rb', line 18 def package(id, folder: FOLDER_DEFAULT, &block) pkg = (@packages_hash[id.to_s] ||= Package.new(self, id, folder: folder)) yield pkg if block pkg end |
#package_ids ⇒ Object
27 28 29 |
# File 'lib/asset_db/group.rb', line 27 def package_ids @packages_hash.keys end |
#packages ⇒ Object
24 25 26 |
# File 'lib/asset_db/group.rb', line 24 def packages @packages_hash.values end |