# Modules/Mixins and accessing the calling object?

**URL:** <https://www.ruby-forum.com/t/modules-mixins-and-accessing-the-calling-object/181609>\
**Category:** Rails\
**Created:** [January 14, 2010, 2:09pm UTC](https://www.ruby-forum.com/t/modules-mixins-and-accessing-the-calling-object/181609 "2010-01-14T14:09:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arne-Kolja\_Bachstei](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b9e5f3/32.png) [@Arne-Kolja\_Bachstei](https://www.ruby-forum.com/u/Arne-Kolja_Bachstei)\
**Post date:** [January 14, 2010, 2:09pm UTC](https://www.ruby-forum.com/t/modules-mixins-and-accessing-the-calling-object/181609/1 "2010-01-14T14:09:56Z")

</div>

Hello there,

I am stuck at a problem regarding modules here. I have a module that’s  
included in my model and I need to get to know the class name of my  
model from within the module. Problem is, that “self” is always  
pointing to the module class (at least I think so) and I do not know  
how to access the calling object.

Here’s the code:

module ActiveRecord  
module Acts  
module AclControlled  
def self.included(base)  
base.send :extend, InstanceMethods  
base.send :extend, ClassMethods  
end

```
  module InstanceMethods
    def controlled_object
      Rails.logger.info "Fetching ControlledObject..."
      controlled_object = ControlledObject.find

```

(:first, :conditions =\> {:model =\> self.class.to\_s, :model\_id =\>  
self.id })  
end  
end

```
  [...]
end

```

end  
end  
ActiveRecord::Base.send :include, ActiveRecord::Acts::AclControlled

Does anyone know how to get access to the calling object here? I tried  
the super object too, but this seems to point to the model without the  
mixin somehow.

Thanks in advance

Arne

---

<div class="post-metadata">

**Author:** ![Arne-Kolja\_Bachstei](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b9e5f3/32.png) [@Arne-Kolja\_Bachstei](https://www.ruby-forum.com/u/Arne-Kolja_Bachstei)\
**Post date:** [January 15, 2010, 11:02am UTC](https://www.ruby-forum.com/t/modules-mixins-and-accessing-the-calling-object/181609/2 "2010-01-15T11:02:47Z")

</div>

Have to close this one, as it was my fault. Didn’t notice that some of  
the methods I want to call are bound to classes rather than objects  
and of course I tested with the wrong ones. Sorry guys, but thanks  
again for your attention 🙂

Cheers

Arne

On 14 Jan., 14:02, Arne-Kolja Bachstein
