Commit d4c91d6

mokha <mokha@cisco.com>
2018-03-10 01:55:39
reduce ABC of method.
1 parent 7f8726b
Changed files (2)
lib
saml
kit
lib/saml/kit/core_ext/assertion.rb
@@ -1,16 +1,22 @@
 module Saml
   module Kit
     class Assertion
+      TABLE = {
+        'Assertion Present?' => ->(x) { x.present? },
+        'Issuer' => ->(x) { x.issuer },
+        'Name Id' => ->(x) { x.name_id },
+        'Attributes' => ->(x) { x.attributes.inspect },
+        'Not Before' => ->(x) { x.started_at },
+        'Not After' => ->(x) { x.expired_at },
+        'Audiences' => ->(x) { x.audiences.inspect },
+        'Encrypted?' => ->(x) { x.encrypted? },
+        'Decryptable' => ->(x) { x.decryptable? },
+      }.freeze
+
       def build_table(table = [])
-        table.push(['Assertion Present?', present?])
-        table.push(['Issuer', issuer])
-        table.push(['Name Id', name_id])
-        table.push(['Attributes', attributes.inspect])
-        table.push(['Not Before', started_at])
-        table.push(['Not After', expired_at])
-        table.push(['Audiences', audiences.inspect])
-        table.push(['Encrypted?', encrypted?])
-        table.push(['Decryptable', decryptable?])
+        TABLE.each do |key, callable|
+          table.push([key, callable.call(self)])
+        end
         signature.build_table(table)
       end
     end
.rubocop.yml
@@ -68,6 +68,12 @@ Style/EachWithObject:
 Style/StringLiterals:
   EnforcedStyle: 'single_quotes'
 
+Style/TrailingCommaInArrayLiteral:
+  Enabled: false
+
+Style/TrailingCommaInHashLiteral:
+  Enabled: false
+
 RSpec/MultipleExpectations:
   Enabled: false