Module: Kashmir::AR::ClassMethods

Defined in:
lib/kashmir/plugins/ar.rb

Instance Method Summary collapse

Instance Method Details

#activerecord_rep(field, options) ⇒ Object



43
44
45
46
# File 'lib/kashmir/plugins/ar.rb', line 43

def activerecord_rep(field, options)
  representation = ActiveRecordRepresentation.new(field, options)
  definitions[field] = representation
end

#reflection_namesObject



35
36
37
38
39
40
41
# File 'lib/kashmir/plugins/ar.rb', line 35

def reflection_names
  if self.respond_to?(:reflections)
    return reflections.keys.map(&:to_sym)
  end

  []
end

#rep(field, options = {}) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/kashmir/plugins/ar.rb', line 27

def rep(field, options={})
  if reflection_names.include?(field)
    return activerecord_rep(field, options)
  end

  super
end