Module: Schizo::Facade::Base
- Defined in:
- lib/schizo/facade/base.rb
Overview
This module is included in each Data object facade’s class.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(mod) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#actualize ⇒ Object
Copy a facade’s instance variables to the object it’s facading for.
-
#initialize(object, role) ⇒ Object
:nodoc:.
-
#instance_of?(klass) ⇒ Boolean
:nodoc:.
Class Method Details
.included(mod) ⇒ Object
:nodoc:
8 9 10 11 12 13 |
# File 'lib/schizo/facade/base.rb', line 8 def self.included(mod) #:nodoc: mod.extend(ClassMethods) mod.class_eval " attr_reader :\#{DCI_INSTANCE_VARIABLE.to_s[1..-1]}\n STR\nend\n" |
Instance Method Details
#actualize ⇒ Object
Copy a facade’s instance variables to the object it’s facading for.
38 39 40 |
# File 'lib/schizo/facade/base.rb', line 38 def actualize dci.object.tap{ |object| Schizo::Facade.copy_instance_variables(self, object) } end |
#initialize(object, role) ⇒ Object
:nodoc:
23 24 25 |
# File 'lib/schizo/facade/base.rb', line 23 def initialize(object, role) #:nodoc: instance_variable_set(DCI_INSTANCE_VARIABLE, Struct.new(:object, :role).new(object, role)) end |
#instance_of?(klass) ⇒ Boolean
:nodoc:
27 28 29 30 31 32 33 34 35 |
# File 'lib/schizo/facade/base.rb', line 27 def instance_of?(klass) #:nodoc: # This is to get it working with nested facades. We need to traverse # superclasses until we get to the first real (non facade) superclass. my_superclass = self.class.superclass while my_superclass.ancestors.include?(Base) and my_superclass my_superclass = my_superclass.superclass end my_superclass == klass end |