Class: FormObj::Struct::Array

Inherits:
TypedArray
  • Object
show all
Defined in:
lib/form_obj/struct/array.rb

Direct Known Subclasses

Form::Array

Instance Method Summary collapse

Instance Method Details

#build(hash = nil, raise_if_not_found: true) ⇒ Object



6
7
8
9
# File 'lib/form_obj/struct/array.rb', line 6

def build(hash = nil, raise_if_not_found: true)
  self << (item = build_item(hash, raise_if_not_found: raise_if_not_found))
  item
end

#create(*args) ⇒ Object



11
12
13
# File 'lib/form_obj/struct/array.rb', line 11

def create(*args)
  build(*args)
end

#to_hashObject



15
16
17
# File 'lib/form_obj/struct/array.rb', line 15

def to_hash
  self.map(&:to_hash)
end

#update_attributes(items, raise_if_not_found:) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/form_obj/struct/array.rb', line 19

def update_attributes(items, raise_if_not_found:)
  items_for_CUD = define_items_for_CUD(items)

  destroy_items(items_for_CUD[:destroy])
  update_items(items_for_CUD[:update], raise_if_not_found: raise_if_not_found)
  build_items(items_for_CUD[:create], raise_if_not_found: raise_if_not_found)

  resort_items_after_CUD!(items)
end