Module: Traits::Association::ReadOnly

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

Instance Method Summary collapse

Instance Method Details

#mutable?Boolean

Returns:

  • (Boolean)


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

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

#readonly?Boolean

Returns:

  • (Boolean)


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

def readonly?
  not mutable?
end

#to_hashObject



15
16
17
# File 'lib/traits/association/read_only.rb', line 15

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