Module: JSON::Schematized::BasicWrapper::SchematizedArray

Defined in:
lib/json/schematized/basic_wrapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#members_moduleObject

Returns the value of attribute members_module.



104
105
106
# File 'lib/json/schematized/basic_wrapper.rb', line 104

def members_module
  @members_module
end

#members_typeObject

Returns the value of attribute members_type.



103
104
105
# File 'lib/json/schematized/basic_wrapper.rb', line 103

def members_type
  @members_type
end

Instance Method Details

#<<(value) ⇒ Object



108
109
110
111
112
113
114
115
116
117
# File 'lib/json/schematized/basic_wrapper.rb', line 108

def <<(value)
  if members_module.json_schema[:type] == "object"
    new_value = members_type.new
    new_value.extend members_module
    new_value.mass_assign!(value) if value.is_a?(Hash)
    super(new_value)
  else
    super
  end
end

#coerce_members_to(*args) ⇒ Object



106
# File 'lib/json/schematized/basic_wrapper.rb', line 106

def coerce_members_to(*args); end

#mass_assign!(array) ⇒ Object



119
120
121
122
123
# File 'lib/json/schematized/basic_wrapper.rb', line 119

def mass_assign!(array)
  array.each do |value|
    self << value
  end
end