Module: Cardiac::Model::Declarations::ClassMethods
- Defined in:
- lib/cardiac/model/declarations.rb
Instance Method Summary collapse
-
#base_resource_with_extensions=(base) ⇒ Object
Overridden to extend the base resource with persistence operations.
-
#resource_with_extensions(base = nil, &declaration) ⇒ Object
Overridden to ensure that the resource is first extended with persistence operations.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object (private)
FIXME: use a more optimized approach that falls back on method_missing.
101 102 103 104 105 106 107 |
# File 'lib/cardiac/model/declarations.rb', line 101 def method_missing(name,*args,&block) if resource_has_extension_method? name perform_operation name, *args, &block else super end end |
Instance Method Details
#base_resource_with_extensions=(base) ⇒ Object
Overridden to extend the base resource with persistence operations.
70 71 72 73 74 75 76 77 |
# File 'lib/cardiac/model/declarations.rb', line 70 def base_resource_with_extensions=(base) case base when ::URI, ::String, ::Cardiac::Resource # Extend the resource with additional declarations before assigning it. base = DeclarationBuilder.new(base).extension_eval(&RESOURCE_EXTENSION_BLOCK) end self.base_resource_without_extensions = base end |
#resource_with_extensions(base = nil, &declaration) ⇒ Object
Overridden to ensure that the resource is first extended with persistence operations.
80 81 82 83 84 85 86 |
# File 'lib/cardiac/model/declarations.rb', line 80 def resource_with_extensions base=nil, &declaration self.base_resource = base if base.present? resource_without_extensions base_resource do instance_eval(&RESOURCE_EXTENSION_BLOCK) instance_eval(&declaration) end end |