Class: PlanMyStuff::BaseMetadata
- Inherits:
-
Object
- Object
- PlanMyStuff::BaseMetadata
- Defined in:
- lib/plan_my_stuff/base_metadata.rb
Direct Known Subclasses
Constant Summary collapse
- SCHEMA_VERSION =
'1'
Instance Attribute Summary collapse
-
#app_name ⇒ String?
Consuming app name from config.
-
#created_at ⇒ Time?
Timestamp of creation.
-
#created_by ⇒ Integer?
Consuming app’s user ID of the creator.
-
#custom_fields ⇒ PlanMyStuff::CustomFields?
App-defined custom field values.
-
#gem_version ⇒ String
Gem version that created this metadata.
-
#rails_env ⇒ String?
Rails environment.
-
#schema_version ⇒ String
Schema version for forward compatibility (starts at “1”).
-
#updated_at ⇒ Time?
Timestamp of last update.
-
#visibility ⇒ String
“public” or “internal”.
Instance Method Summary collapse
-
#initialize ⇒ BaseMetadata
constructor
A new instance of BaseMetadata.
- #internal? ⇒ Boolean
- #public? ⇒ Boolean
- #to_h ⇒ Hash
- #to_json ⇒ String
Constructor Details
#initialize ⇒ BaseMetadata
Returns a new instance of BaseMetadata.
93 94 95 |
# File 'lib/plan_my_stuff/base_metadata.rb', line 93 def initialize @visibility = 'internal' end |
Instance Attribute Details
#app_name ⇒ String?
Returns consuming app name from config.
17 18 19 |
# File 'lib/plan_my_stuff/base_metadata.rb', line 17 def app_name @app_name end |
#created_at ⇒ Time?
Returns timestamp of creation.
19 20 21 |
# File 'lib/plan_my_stuff/base_metadata.rb', line 19 def created_at @created_at end |
#created_by ⇒ Integer?
Returns consuming app’s user ID of the creator.
23 24 25 |
# File 'lib/plan_my_stuff/base_metadata.rb', line 23 def created_by @created_by end |
#custom_fields ⇒ PlanMyStuff::CustomFields?
Returns app-defined custom field values.
27 28 29 |
# File 'lib/plan_my_stuff/base_metadata.rb', line 27 def custom_fields @custom_fields end |
#gem_version ⇒ String
Returns gem version that created this metadata.
13 14 15 |
# File 'lib/plan_my_stuff/base_metadata.rb', line 13 def gem_version @gem_version end |
#rails_env ⇒ String?
Returns Rails environment.
15 16 17 |
# File 'lib/plan_my_stuff/base_metadata.rb', line 15 def rails_env @rails_env end |
#schema_version ⇒ String
Returns schema version for forward compatibility (starts at “1”).
11 12 13 |
# File 'lib/plan_my_stuff/base_metadata.rb', line 11 def schema_version @schema_version end |
#updated_at ⇒ Time?
Returns timestamp of last update.
21 22 23 |
# File 'lib/plan_my_stuff/base_metadata.rb', line 21 def updated_at @updated_at end |
#visibility ⇒ String
Returns “public” or “internal”.
25 26 27 |
# File 'lib/plan_my_stuff/base_metadata.rb', line 25 def visibility @visibility end |
Instance Method Details
#internal? ⇒ Boolean
113 114 115 |
# File 'lib/plan_my_stuff/base_metadata.rb', line 113 def internal? visibility == 'internal' end |
#public? ⇒ Boolean
118 119 120 |
# File 'lib/plan_my_stuff/base_metadata.rb', line 118 def public? visibility == 'public' end |
#to_h ⇒ Hash
98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/plan_my_stuff/base_metadata.rb', line 98 def to_h { schema_version: schema_version, gem_version: gem_version, rails_env: rails_env, app_name: app_name, created_at: format_time(created_at), updated_at: format_time(updated_at), created_by: created_by, visibility: visibility, custom_fields: custom_fields.to_h, } end |
#to_json ⇒ String
123 124 125 |
# File 'lib/plan_my_stuff/base_metadata.rb', line 123 def to_json(...) to_h.to_json(...) end |