Method: Binda::FieldableAssociationHelpers::FieldableRepeaterHelpers#get_repeaters

Defined in:
app/models/concerns/binda/fieldable_association_helpers/fieldable_repeater_helpers.rb

#get_repeaters(field_slug) ⇒ array

Get the all repeater instances sorted by position

Parameters:

  • field_slug (string)

    The slug of the field setting

Returns:

  • (array)

    An array of repeater items which have all sorts of fields attached

Raises:

  • (ArgumentError)


21
22
23
24
25
# File 'app/models/concerns/binda/fieldable_association_helpers/fieldable_repeater_helpers.rb', line 21

def get_repeaters(field_slug)
	obj = self.repeaters.find_all{ |t| t.field_setting_id == FieldSetting.get_id( field_slug ) }
	raise ArgumentError, "There isn't any repeater associated to the current slug (#{field_slug}) on instance (#{self.class.name} ##{self.id}).", caller if obj.nil?
	obj.sort_by(&:position)
end