Class: SafeDb::Set

Inherits:
Controller show all
Defined in:
lib/controller/set.rb

Overview

The set use case is the generic tool for setting book scoped configuration directives. These directives can only be read, written, updated or removed during a logged in branch.

The mirror of this use case is unset.

Observable Value

The configuration directive will either be created or overwriten within the book’s configuration store.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Controller

#check_post_conditions, #check_pre_conditions, #flow, #initialize, #open_remote_backend_location, #post_validation, #pre_validation, #read_verse, #set_verse, #update_verse

Constructor Details

This class inherits a constructor from SafeDb::Controller

Instance Attribute Details

#directive_name=(value) ⇒ Object (writeonly)

Sets the attribute directive_name

Parameters:

  • value

    the value to set the attribute directive_name to.



18
19
20
# File 'lib/controller/set.rb', line 18

def directive_name=(value)
  @directive_name = value
end

#directive_value=(value) ⇒ Object (writeonly)

Sets the attribute directive_value

Parameters:

  • value

    the value to set the attribute directive_value to.



18
19
20
# File 'lib/controller/set.rb', line 18

def directive_value=(value)
  @directive_value = value
end

Instance Method Details

#executeObject

The set use case is the generic tool for setting book scoped configuration directives. These directives can only be read, written, updated or removed during a logged in branch.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/controller/set.rb', line 23

def execute

  return unless ops_key_exists?
  master_db = Book.read()

  master_db[ @directive_name ] = @directive_value

  puts ""
  puts JSON.pretty_generate( master_db )
  puts ""

  Book.write( create_header(), master_db )

end