module ScientificProtocols::Resources::Object::Attributes
Public Class Methods
included(base)
click to toggle source
Calls superclass method
# File lib/scientificprotocols/resources/object/attributes.rb, line 35 def self.included(base) base.extend(ClassMethods) super end
Public Instance Methods
attributes()
click to toggle source
# File lib/scientificprotocols/resources/object/attributes.rb, line 40 def attributes {}.tap do |result| __getobj__.keys.each do |key| attribute = key.to_s.downcase result[attribute] = public_send(attribute) end end end
method_missing(name, *args, &block)
click to toggle source
Calls superclass method
# File lib/scientificprotocols/resources/object/attributes.rb, line 49 def method_missing(name, *args, &block) attribute = name.to_s.upcase if __getobj__.key?(attribute) self.class.define_attribute_accessor(name) deserialize_attribute(name, self.class.attributes[name.to_sym]) else super end end
Private Instance Methods
deserialize_attribute(name, type)
click to toggle source
@param [String, Symbol] name @param [Class, to_s] type
# File lib/scientificprotocols/resources/object/attributes.rb, line 67 def deserialize_attribute(name, type) raw = __getobj__[name.to_s.upcase] self.class.serializer_for(type).deserialize(raw) end
respond_to_missing?(name, include_all = false)
click to toggle source
Calls superclass method
# File lib/scientificprotocols/resources/object/attributes.rb, line 61 def respond_to_missing?(name, include_all = false) __getobj__.key?(name.to_s.upcase) || super(name, include_all) end