Class: Foobara::AWS::Plan
- Inherits:
-
Data
- Object
- Data
- Foobara::AWS::Plan
- Defined in:
- lib/foobara/aws/plan.rb
Overview
The whole topology, read out of a Foobara manifest.
Deliberately plain data. It is built where the manifest is (a running connector, or a file), travels as JSON, and is consumed where the infrastructure is — which may be a different process with none of the application's gems. Same split as the Service construct's, and the same reason: synthesis should depend on what was built, not on whether the app happens to load.
Instance Attribute Summary collapse
-
#granularity ⇒ Object
readonly
Returns the value of attribute granularity.
-
#mount ⇒ Object
readonly
Returns the value of attribute mount.
-
#units ⇒ Object
readonly
Returns the value of attribute units.
Class Method Summary collapse
-
.load(data) ⇒ Object
The inverse of #to_h, for a plan that has been through JSON.
Instance Method Summary collapse
-
#anonymous ⇒ Object
Every command callable without authentication, across all units.
- #to_h ⇒ Object
- #to_json(*args) ⇒ Object
- #unit(name) ⇒ Object
Instance Attribute Details
#granularity ⇒ Object (readonly)
Returns the value of attribute granularity
25 26 27 |
# File 'lib/foobara/aws/plan.rb', line 25 def granularity @granularity end |
#mount ⇒ Object (readonly)
Returns the value of attribute mount
25 26 27 |
# File 'lib/foobara/aws/plan.rb', line 25 def mount @mount end |
#units ⇒ Object (readonly)
Returns the value of attribute units
25 26 27 |
# File 'lib/foobara/aws/plan.rb', line 25 def units @units end |
Class Method Details
.load(data) ⇒ Object
The inverse of #to_h, for a plan that has been through JSON.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/foobara/aws/plan.rb', line 49 def self.load(data) data = data.transform_keys(&:to_s) new( mount: data.fetch("mount"), granularity: data.fetch("granularity").to_sym, units: data.fetch("units").map do |u| u = u.transform_keys(&:to_s) Unit.new(name: u.fetch("name"), group: u["group"], commands: u.fetch("commands"), route: u["route"], public_commands: u.fetch("public_commands", []), sizing: (u["sizing"] || {}).to_h { |k, v| [k.to_sym, v] }) end ) end |
Instance Method Details
#anonymous ⇒ Object
Every command callable without authentication, across all units. This is
what an optional-auth authorizer needs, and it is derived rather than
maintained — a command moves in or out of it by declaring
requires_authentication, nowhere else.
30 |
# File 'lib/foobara/aws/plan.rb', line 30 def anonymous = units.flat_map(&:public_commands).sort |
#to_h ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/foobara/aws/plan.rb', line 34 def to_h { "mount" => mount, "granularity" => granularity.to_s, "units" => units.map do |u| { "name" => u.name, "group" => u.group, "commands" => u.commands, "route" => u.route, "public_commands" => u.public_commands, "sizing" => u.sizing } end } end |
#to_json(*args) ⇒ Object
46 |
# File 'lib/foobara/aws/plan.rb', line 46 def to_json(*args) = to_h.to_json(*args) |
#unit(name) ⇒ Object
32 |
# File 'lib/foobara/aws/plan.rb', line 32 def unit(name) = units.find { |u| u.name == name.to_s } |