Class: Disposable::Expose
- Inherits:
-
Object
- Object
- Disposable::Expose
- Includes:
- Save
- Defined in:
- lib/disposable/expose.rb
Overview
Expose allows renaming properties in order to expose a different API. It can be configured from any Representable schema.
class AlbumTwin < Disposable::Twin
property :name, from: :title
end
class AlbumExpose < Disposable::Expose
from AlbumTwin
end
AlbumExpose.new(OpenStruct.new(title: "AFI")).name #=> "AFI"
Direct Known Subclasses
Defined Under Namespace
Modules: Save
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(model) ⇒ Expose
constructor
A new instance of Expose.
Methods included from Save
Constructor Details
#initialize(model) ⇒ Expose
Returns a new instance of Expose.
38 39 40 |
# File 'lib/disposable/expose.rb', line 38 def initialize(model) @model = model end |
Class Method Details
.from(schema) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/disposable/expose.rb', line 16 def from(schema) schema.each do |definition| process_definition!(definition) end self end |