Module: HasUuid::ActiveRecord::Associations::Builder::SingularAssociation::RedefinedWriter

Defined in:
lib/has_uuid/active_record/associations/builder/singular_association.rb

Instance Method Summary collapse

Instance Method Details

#define_writers_with_uuid(mixin, name) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/has_uuid/active_record/associations/builder/singular_association.rb', line 25

def define_writers_with_uuid(mixin, name)
  mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
    def #{name.to_s.singularize}_uuid=(uuids)
      association(:#{name}).uuid_writer(uuids)
    end

    def #{name.to_s.singularize}_uuid
      association(:#{name}).uuid_reader
    end
  CODE
end

#define_writers_with_uuid_args(mixin, name) ⇒ Object



37
38
39
40
# File 'lib/has_uuid/active_record/associations/builder/singular_association.rb', line 37

def define_writers_with_uuid_args(mixin, name)
  define_writers_without_uuid_args(mixin, name)
  define_writers_with_uuid(mixin, name)
end

#define_writers_with_uuid_no_argsObject



42
43
44
45
# File 'lib/has_uuid/active_record/associations/builder/singular_association.rb', line 42

def define_writers_with_uuid_no_args
  define_writers_without_uuid_no_args
  define_writers_with_uuid(mixin, name)
end