Module: Traits::Association::ReadOnly

Included in:
Traits::Association
Defined in:
lib/traits/concerns/association/read_only.rb

Instance Method Summary collapse

Instance Method Details

#mutable?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/traits/concerns/association/read_only.rb', line 4

def mutable?
  !through? || source_association.macro == :belongs_to
end

#readonly?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/traits/concerns/association/read_only.rb', line 8

def readonly?
  not mutable?
end

#to_hashObject



12
13
14
# File 'lib/traits/concerns/association/read_only.rb', line 12

def to_hash
  super.merge!(mutable: mutable?)
end