Class: ModelSerializer
- Inherits:
-
ApplicationSerializer
- Object
- ApplicationSerializer
- ModelSerializer
- Defined in:
- app/serializers/model_serializer.rb
Instance Attribute Summary collapse
-
#macro ⇒ Object
readonly
Returns the value of attribute macro.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
-
#initialize(model:, macro:, parent: nil) ⇒ ModelSerializer
constructor
A new instance of ModelSerializer.
- #to_h ⇒ Object
Methods inherited from ApplicationSerializer
Constructor Details
#initialize(model:, macro:, parent: nil) ⇒ ModelSerializer
Returns a new instance of ModelSerializer.
6 7 8 9 10 |
# File 'app/serializers/model_serializer.rb', line 6 def initialize(model:, macro:, parent: nil) @model = model @macro = macro @parent = parent end |
Instance Attribute Details
#macro ⇒ Object (readonly)
Returns the value of attribute macro.
4 5 6 |
# File 'app/serializers/model_serializer.rb', line 4 def macro @macro end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
4 5 6 |
# File 'app/serializers/model_serializer.rb', line 4 def model @model end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
4 5 6 |
# File 'app/serializers/model_serializer.rb', line 4 def parent @parent end |
Instance Method Details
#to_h ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'app/serializers/model_serializer.rb', line 12 def to_h { model: model.name, columns: model.column_names, scopes: build_scopes, associations: build_associations } end |