Class: CrudComponents::Admin::Dependents::Item

Inherits:
Struct
  • Object
show all
Defined in:
lib/crud_components/admin/dependents.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#behaviorObject

Returns the value of attribute behavior

Returns:

  • (Object)

    the current value of behavior



12
13
14
# File 'lib/crud_components/admin/dependents.rb', line 12

def behavior
  @behavior
end

#cascadesObject

Returns the value of attribute cascades

Returns:

  • (Object)

    the current value of cascades



12
13
14
# File 'lib/crud_components/admin/dependents.rb', line 12

def cascades
  @cascades
end

#countObject

Returns the value of attribute count

Returns:

  • (Object)

    the current value of count



12
13
14
# File 'lib/crud_components/admin/dependents.rb', line 12

def count
  @count
end

#modelObject

Returns the value of attribute model

Returns:

  • (Object)

    the current value of model



12
13
14
# File 'lib/crud_components/admin/dependents.rb', line 12

def model
  @model
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



12
13
14
# File 'lib/crud_components/admin/dependents.rb', line 12

def name
  @name
end

#recordsObject

Returns the value of attribute records

Returns:

  • (Object)

    the current value of records



12
13
14
# File 'lib/crud_components/admin/dependents.rb', line 12

def records
  @records
end

Instance Method Details

#blocks?Boolean

Returns:

  • (Boolean)


18
# File 'lib/crud_components/admin/dependents.rb', line 18

def blocks? = BLOCKING.include?(behavior) && count.positive?

#destroys?Boolean

Returns:

  • (Boolean)


13
# File 'lib/crud_components/admin/dependents.rb', line 13

def destroys? = DESTROYING.include?(behavior)

#human_nameObject



22
23
24
25
# File 'lib/crud_components/admin/dependents.rb', line 22

def human_name
  human = model ? model.model_name.human(count: count) : name.to_s.humanize
  count == 1 ? human : human.pluralize(I18n.locale)
end

#nullifies?Boolean

Returns:

  • (Boolean)


20
# File 'lib/crud_components/admin/dependents.rb', line 20

def nullifies? = behavior == :nullify

#unnamedObject

What is left over once the named ones are shown.



16
# File 'lib/crud_components/admin/dependents.rb', line 16

def unnamed = count - Array(records).size