Class: RawColumn::JsonProxy
- Inherits:
-
Object
- Object
- RawColumn::JsonProxy
- Defined in:
- lib/raw_column/json_proxy.rb
Instance Method Summary collapse
- #as_json(*args) ⇒ Object
- #encode_json(encoder) ⇒ Object
-
#initialize(record, column_name) ⇒ JsonProxy
constructor
A new instance of JsonProxy.
Constructor Details
#initialize(record, column_name) ⇒ JsonProxy
Returns a new instance of JsonProxy.
7 8 9 10 11 12 13 |
# File 'lib/raw_column/json_proxy.rb', line 7 def initialize(record, column_name) method = :"#{column_name}_before_type_cast" unless record.respond_to?(method) raise BeforeTypeCastError.new("your column must respond to #{method}") end @raw_content = record.send(method) end |
Instance Method Details
#as_json(*args) ⇒ Object
15 16 17 |
# File 'lib/raw_column/json_proxy.rb', line 15 def as_json(*args) self end |
#encode_json(encoder) ⇒ Object
19 20 21 |
# File 'lib/raw_column/json_proxy.rb', line 19 def encode_json(encoder) @raw_content end |