Class: PlanMyStuff::ProjectMetadata

Inherits:
BaseProjectMetadata show all
Defined in:
lib/plan_my_stuff/project_metadata.rb

Overview

Metadata for regular (non-testing) projects.

Constant Summary

Constants inherited from BaseMetadata

BaseMetadata::SCHEMA_VERSION

Instance Attribute Summary

Attributes inherited from BaseProjectMetadata

#kind

Attributes inherited from BaseMetadata

#app_name, #created_by, #custom_fields, #gem_version, #rails_env, #schema_version, #visibility

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseProjectMetadata

#to_h

Methods inherited from BaseMetadata

#internal?, #public?, #to_h, #to_json, #validate_custom_fields!

Constructor Details

#initializeProjectMetadata

Returns a new instance of ProjectMetadata.



42
43
44
45
# File 'lib/plan_my_stuff/project_metadata.rb', line 42

def initialize
  super
  @kind = 'project'
end

Class Method Details

.build(user:, visibility: 'internal', custom_fields: {}) ⇒ PlanMyStuff::ProjectMetadata

Builds a new ProjectMetadata for project creation, auto-filling gem defaults

Parameters:

  • user (Object, Integer)

    user object or user_id

  • visibility (String) (defaults to: 'internal')

    “public” or “internal”

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

    app-defined field values

Returns:



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/plan_my_stuff/project_metadata.rb', line 28

def build(user:, visibility: 'internal', custom_fields: {})
   = new
  apply_common_build(
    ,
    user: user,
    visibility: visibility,
    custom_fields_data: custom_fields,
    custom_fields_schema: PlanMyStuff.configuration.custom_fields_for(:project),
  )
  .kind = 'project'
  
end

.from_hash(hash) ⇒ PlanMyStuff::ProjectMetadata

Builds a ProjectMetadata from a parsed hash (e.g. from MetadataParser)

Parameters:

  • hash (Hash)

Returns:



13
14
15
16
17
18
# File 'lib/plan_my_stuff/project_metadata.rb', line 13

def from_hash(hash)
   = new
  apply_common_from_hash(, hash, PlanMyStuff.configuration.custom_fields_for(:project))
  .kind = hash.fetch(:kind, 'project')
  
end