Class: Realm::ROM::ReadOnlyRelationWrapper
- Inherits:
-
Object
- Object
- Realm::ROM::ReadOnlyRelationWrapper
- Defined in:
- lib/realm/rom/read_only_relation_wrapper.rb
Constant Summary collapse
- FORBIDDEN_METHODS =
(::ROM::SQL::Relation::Writing.instance_methods(false) + [:command]).freeze
Instance Method Summary collapse
-
#initialize(relation) ⇒ ReadOnlyRelationWrapper
constructor
A new instance of ReadOnlyRelationWrapper.
- #method_missing(symbol, *args) ⇒ Object
- #respond_to_missing?(symbol) ⇒ Boolean
Constructor Details
#initialize(relation) ⇒ ReadOnlyRelationWrapper
Returns a new instance of ReadOnlyRelationWrapper.
8 9 10 |
# File 'lib/realm/rom/read_only_relation_wrapper.rb', line 8 def initialize(relation) @relation = relation end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args) ⇒ Object
12 13 14 15 16 |
# File 'lib/realm/rom/read_only_relation_wrapper.rb', line 12 def method_missing(symbol, *args) raise Persistence::RelationIsReadOnly, @relation if FORBIDDEN_METHODS.include?(symbol) @relation.send(symbol, *args) end |
Instance Method Details
#respond_to_missing?(symbol) ⇒ Boolean
18 19 20 |
# File 'lib/realm/rom/read_only_relation_wrapper.rb', line 18 def respond_to_missing?(symbol) !FORBIDDEN_METHODS.include?(symbol) && @relation.respond_to?(symbol) end |