Module: OpenActive::Concerns::JsonLdSerializable

Included in:
BaseModel
Defined in:
lib/openactive/concerns/json_ld_serializable.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
# File 'lib/openactive/concerns/json_ld_serializable.rb', line 4

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#to_hObject



34
35
36
37
38
39
40
# File 'lib/openactive/concerns/json_ld_serializable.rb', line 34

def to_h
  data = {}
  self.class.properties.each do |_key, field:|
    data[field] = send(field)
  end
  data
end

#valuesObject



26
27
28
29
30
31
32
# File 'lib/openactive/concerns/json_ld_serializable.rb', line 26

def values
  data = {}
  self.class.properties.each do |key, field:|
    data[key] = send(field)
  end
  data
end