Class: Opium::Model::Reference
- Defined in:
- lib/opium/model/reference.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
Class Method Summary collapse
Instance Method Summary collapse
- #__getobj__ ⇒ Object
- #__setobj__(obj) ⇒ Object
-
#initialize(metadata, context) ⇒ Reference
constructor
A new instance of Reference.
- #inspect ⇒ Object
Constructor Details
#initialize(metadata, context) ⇒ Reference
Returns a new instance of Reference.
17 18 19 20 21 22 |
# File 'lib/opium/model/reference.rb', line 17 def initialize( , context ) self. = self.context = context fail ArgumentError, 'did not receive a context object!' unless context super( nil ) end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
24 25 26 |
# File 'lib/opium/model/reference.rb', line 24 def context @context end |
#metadata ⇒ Object
Returns the value of attribute metadata.
24 25 26 |
# File 'lib/opium/model/reference.rb', line 24 def @metadata end |
Class Method Details
.to_ruby(value) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/opium/model/reference.rb', line 5 def to_ruby( value ) case value when Hash new( value[:metadata] || value['metadata'], value[:context] || value['context'] ) when self value else fail ArgumentError, "could not convert #{ value.inspect } into an Opium::Model::Reference" end end |
Instance Method Details
#__getobj__ ⇒ Object
26 27 28 |
# File 'lib/opium/model/reference.rb', line 26 def __getobj__ @reference || __setobj__( lookup_reference ) end |
#__setobj__(obj) ⇒ Object
30 31 32 |
# File 'lib/opium/model/reference.rb', line 30 def __setobj__( obj ) @reference = obj end |
#inspect ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/opium/model/reference.rb', line 34 def inspect if @reference @reference.inspect else "#<#{ self.class.name }<#{ self..target_class_name }>>" end end |