Class: IMS::LTI::Serializers::Base
- Inherits:
-
Object
- Object
- IMS::LTI::Serializers::Base
show all
- Defined in:
- lib/ims/lti/serializers/base.rb
Defined Under Namespace
Classes: Filter
Class Method Summary
collapse
Class Method Details
.as_json(obj) ⇒ Object
101
102
103
|
# File 'lib/ims/lti/serializers/base.rb', line 101
def self.as_json(obj)
@filter.filter(base_hash(obj))
end
|
.attributes ⇒ Object
113
114
115
|
# File 'lib/ims/lti/serializers/base.rb', line 113
def self.attributes
@attributes
end
|
.has_list_of_serializables(name, opts = {}) ⇒ Object
95
96
97
98
99
|
# File 'lib/ims/lti/serializers/base.rb', line 95
def self.has_list_of_serializables(name, opts={})
opts[:list_of_serializables] = true
opts[:serializable] = false
set_attribute(name, opts)
end
|
.has_serializable(name, opts = {}) ⇒ Object
89
90
91
92
93
|
# File 'lib/ims/lti/serializers/base.rb', line 89
def self.has_serializable(name, opts={})
opts[:serializable] = true
opts[:list_of_serializables] = false
set_attribute(name, opts)
end
|
.inherited(subclass) ⇒ Object
75
76
77
78
|
# File 'lib/ims/lti/serializers/base.rb', line 75
def self.inherited(subclass)
subclass.instance_variable_set(:@filter, Filter.new)
subclass.instance_variable_set(:@attributes, Set.new)
end
|
.options_for_attribute(attribute) ⇒ Object
109
110
111
|
# File 'lib/ims/lti/serializers/base.rb', line 109
def self.options_for_attribute(attribute)
@filter.options_for_attribute(attribute)
end
|
.set_attribute(name, opts = {}) ⇒ Object
80
81
82
83
|
# File 'lib/ims/lti/serializers/base.rb', line 80
def self.set_attribute(name, opts={})
@attributes.add(name)
@filter.add_filter(name, opts)
end
|
.set_attributes(*names) ⇒ Object
85
86
87
|
# File 'lib/ims/lti/serializers/base.rb', line 85
def self.set_attributes(*names)
names.each { |name| set_attribute(name) }
end
|
.to_json(obj) ⇒ Object
105
106
107
|
# File 'lib/ims/lti/serializers/base.rb', line 105
def self.to_json(obj)
as_json(obj).to_json
end
|