Module: ObjectAttorney::Representation::ClassMethods
- Defined in:
- lib/object_attorney/representation.rb
Instance Method Summary collapse
- #represented_object_class ⇒ Object
- #represented_object_reflect_on_association(association) ⇒ Object
- #represented_object_reflection ⇒ Object
- #represents(represented_object_name, options = {}) ⇒ Object
Instance Method Details
#represented_object_class ⇒ Object
73 74 75 |
# File 'lib/object_attorney/representation.rb', line 73 def represented_object_class represented_object_reflection.try(:klass) end |
#represented_object_reflect_on_association(association) ⇒ Object
77 78 79 80 81 |
# File 'lib/object_attorney/representation.rb', line 77 def represented_object_reflect_on_association(association) return nil if represented_object_class.nil? || !represented_object_class.respond_to?(:reflect_on_association) represented_object_class.reflect_on_association(association) end |
#represented_object_reflection ⇒ Object
69 70 71 |
# File 'lib/object_attorney/representation.rb', line 69 def represented_object_reflection self.instance_variable_get("@represented_object_reflection") || zuper_method('represented_object_reflection') end |
#represents(represented_object_name, options = {}) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/object_attorney/representation.rb', line 57 def represents(represented_object_name, = {}) self.instance_variable_set("@represented_object_reflection", Reflection.new(represented_object_name, )) define_method(represented_object_name) { represented_object } properties(*[:properties]) if .include?(:properties) getters(*[:getters]) if .include?(:getters) setters(*[:setters]) if .include?(:setters) class_eval { include Delegation::MissingMethods } if [:delegate_missing_methods] end |