Module: JSON::Encodable::ClassMethods

Defined in:
lib/json/encodable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#property_namesArray

Stores property names, used to build JSON properties

Returns:

  • (Array)


90
91
92
# File 'lib/json/encodable.rb', line 90

def property_names
  @property_names ||= []
end

Instance Method Details

#inherited(child) ⇒ Object

Note:

Override

Inherits property_names, while they are not shared between a parent and their children



102
103
104
105
# File 'lib/json/encodable.rb', line 102

def inherited(child)
  super
  child.property_names = property_names.clone
end

#property(property_name) ⇒ Object

Defines a given property name as a property of the JSON prepresentation its class

Parameters:

  • normal_property_name (Symbol)


96
97
98
# File 'lib/json/encodable.rb', line 96

def property(property_name)
  property_names << property_name
end