Class: Shaf::ALPS::JsonSerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/shaf/alps/json_serializer.rb

Constant Summary collapse

ALPS_VERSION =
'1.0'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(profile) ⇒ JsonSerializer

Returns a new instance of JsonSerializer.



17
18
19
# File 'lib/shaf/alps/json_serializer.rb', line 17

def initialize(profile)
  @profile = profile
end

Instance Attribute Details

#profileObject (readonly)

Returns the value of attribute profile.



15
16
17
# File 'lib/shaf/alps/json_serializer.rb', line 15

def profile
  @profile
end

Class Method Details

.call(profile) ⇒ Object



11
12
13
# File 'lib/shaf/alps/json_serializer.rb', line 11

def self.call(profile)
  new(profile).to_hash
end

Instance Method Details

#to_hashObject



21
22
23
24
25
26
27
28
29
# File 'lib/shaf/alps/json_serializer.rb', line 21

def to_hash
  {
    alps: {
      version: ALPS_VERSION,
      doc: profile.doc,
      descriptor: descriptors,
    }.compact
  }
end