Module: GoodData::Mixin::Lockable
- Included in:
- Dashboard, GoodData::Metric, Report, ScheduledMail
- Defined in:
- lib/gooddata/mixins/md_lock.rb
Instance Method Summary collapse
-
#lock ⇒ GoodData::Mixin::Lockable
Locks an object.
-
#lock! ⇒ GoodData::Mixin::Lockable
Sames as #lock.
-
#lock_with_dependencies! ⇒ GoodData::Mixin::Lockable
Locks an object with all used objects.
-
#locked? ⇒ Boolean
Returns true if an object is locked.
-
#unlock ⇒ GoodData::Mixin::Lockable
Unlocks an object.
-
#unlock! ⇒ GoodData::Mixin::Lockable
Same as #unlock.
-
#unlock_with_dependencies! ⇒ GoodData::Mixin::Lockable
Unlocks an object with all used objects.
-
#unlocked? ⇒ Boolean
Returns true if an object is unlocked.
Instance Method Details
#lock ⇒ GoodData::Mixin::Lockable
Locks an object. Locked object cannot be changed by certain users.
13 14 15 16 |
# File 'lib/gooddata/mixins/md_lock.rb', line 13 def lock ['locked'] = 1 self end |
#lock! ⇒ GoodData::Mixin::Lockable
Sames as #lock. Locks an object and immediately saves it.
21 22 23 24 |
# File 'lib/gooddata/mixins/md_lock.rb', line 21 def lock! lock save end |
#lock_with_dependencies! ⇒ GoodData::Mixin::Lockable
Locks an object with all used objects. The types of objects that are affected by locks are dashboards, reports and metrics. This means that if you lock a dashboard by this method all used reports and metrics are also locked. If you lock a report all used metrics are also locked. The current object is reloaded. This means that the #locked? will return true.
48 49 50 51 52 53 54 55 |
# File 'lib/gooddata/mixins/md_lock.rb', line 48 def lock_with_dependencies! client.post("/gdc/internal/projects/#{project.pid}/objects/setPermissions", permissions: { lock: true, items: [uri] }) reload! end |
#locked? ⇒ Boolean
Returns true if an object is locked. False otherwise.
75 76 77 |
# File 'lib/gooddata/mixins/md_lock.rb', line 75 def locked? ['locked'] == 1 end |
#unlock ⇒ GoodData::Mixin::Lockable
Unlocks an object.
29 30 31 32 |
# File 'lib/gooddata/mixins/md_lock.rb', line 29 def unlock .delete('locked') self end |
#unlock! ⇒ GoodData::Mixin::Lockable
Same as #unlock. Unlocks an object and immediately saves it
37 38 39 40 |
# File 'lib/gooddata/mixins/md_lock.rb', line 37 def unlock! unlock save end |
#unlock_with_dependencies! ⇒ GoodData::Mixin::Lockable
Unlocks an object with all used objects. The types of objects that are affected by locks are dashboards, reports and metrics. This means that if you unlock a dashboard by this method all used reports and metrics are also unlocked. If you unlock a report all used metrics are also unlocked. The current object is unlocked as well. Beware that certain objects might be in use in multiple contexts. For example one metric can be used in several reports. This method performs no checks to determine if an object should stay locked or not.
65 66 67 68 69 70 |
# File 'lib/gooddata/mixins/md_lock.rb', line 65 def unlock_with_dependencies! using('report').pmap { |link| project.reports(link['link']) }.select(&:locked?).pmap(&:unlock!) using('metric').pmap { |link| project.metrics(link['link']) }.select(&:locked?).pmap(&:unlock!) using('projectDashboard').pmap { |link| project.dashboards(link['link']) }.select(&:locked?).pmap(&:unlock!) unlock! end |
#unlocked? ⇒ Boolean
Returns true if an object is unlocked. False otherwise.
82 83 84 |
# File 'lib/gooddata/mixins/md_lock.rb', line 82 def unlocked? !locked? end |