Skip to content

Commit 8c656a9

Browse files
committed
Improve variable assignment readability
The assignment of the @type instance variable in Puppet::Pops::Context#register_ptype resulted in poor readability due to the number of arguments in the Pcore::create_object_type method call and the number of those arguments that are nested hashes. This commit reformats this assignment for easier readability and shorter line lengths.
1 parent 9745498 commit 8c656a9

File tree

1 file changed

+32
-25
lines changed

1 file changed

+32
-25
lines changed

lib/puppet/pops/lookup/context.rb

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -134,31 +134,38 @@ def self._pcore_type
134134
def self.register_ptype(loader, ir)
135135
tf = Types::TypeFactory
136136
key_type = tf.optional(tf.scalar)
137-
@type = Pcore::create_object_type(loader, ir, self, 'Puppet::LookupContext', 'Any',
138-
{
139-
'environment_name' => {
140-
Types::KEY_TYPE => Types::PStringType::NON_EMPTY,
141-
Types::KEY_KIND => Types::PObjectType::ATTRIBUTE_KIND_DERIVED
142-
},
143-
'module_name' => {
144-
Types::KEY_TYPE => tf.variant(Types::PStringType::NON_EMPTY, Types::PUndefType::DEFAULT)
145-
}
146-
},
147-
{
148-
'not_found' => tf.callable([0, 0], tf.undef),
149-
'explain' => tf.callable([0, 0, tf.callable(0,0)], tf.undef),
150-
'interpolate' => tf.callable(1, 1),
151-
'cache' => tf.callable([key_type, tf.any], tf.any),
152-
'cache_all' => tf.callable([tf.hash_kv(key_type, tf.any)], tf.undef),
153-
'cache_has_key' => tf.callable([key_type], tf.boolean),
154-
'cached_value' => tf.callable([key_type], tf.any),
155-
'cached_entries' => tf.variant(
156-
tf.callable([0, 0, tf.callable(1,1)], tf.undef),
157-
tf.callable([0, 0, tf.callable(2,2)], tf.undef),
158-
tf.callable([0, 0], tf.iterable(tf.tuple([key_type, tf.any])))
159-
),
160-
'cached_file_data' => tf.callable(tf.string, tf.optional(tf.callable([1, 1])))
161-
}).resolve(loader)
137+
@type =
138+
Pcore::create_object_type(
139+
loader,
140+
ir,
141+
self,
142+
'Puppet::LookupContext',
143+
'Any',
144+
{
145+
'environment_name' => {
146+
Types::KEY_TYPE => Types::PStringType::NON_EMPTY,
147+
Types::KEY_KIND => Types::PObjectType::ATTRIBUTE_KIND_DERIVED
148+
},
149+
'module_name' => {
150+
Types::KEY_TYPE => tf.variant(Types::PStringType::NON_EMPTY, Types::PUndefType::DEFAULT)
151+
}
152+
},
153+
{
154+
'not_found' => tf.callable([0, 0], tf.undef),
155+
'explain' => tf.callable([0, 0, tf.callable(0,0)], tf.undef),
156+
'interpolate' => tf.callable(1, 1),
157+
'cache' => tf.callable([key_type, tf.any], tf.any),
158+
'cache_all' => tf.callable([tf.hash_kv(key_type, tf.any)], tf.undef),
159+
'cache_has_key' => tf.callable([key_type], tf.boolean),
160+
'cached_value' => tf.callable([key_type], tf.any),
161+
'cached_entries' => tf.variant(
162+
tf.callable([0, 0, tf.callable(1,1)], tf.undef),
163+
tf.callable([0, 0, tf.callable(2,2)], tf.undef),
164+
tf.callable([0, 0], tf.iterable(tf.tuple([key_type, tf.any])))
165+
),
166+
'cached_file_data' => tf.callable(tf.string, tf.optional(tf.callable([1, 1])))
167+
}
168+
).resolve(loader)
162169
end
163170

164171
# Mainly for test purposes. Makes it possible to create a {Context} in Puppet code provided that a current {Invocation} exists.

0 commit comments

Comments
 (0)