Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delegate surrealization to parent class #11

Closed
nesaulov opened this issue Oct 4, 2017 · 2 comments
Closed

Delegate surrealization to parent class #11

nesaulov opened this issue Oct 4, 2017 · 2 comments

Comments

@nesaulov
Copy link
Owner

nesaulov commented Oct 4, 2017

Considering this example:

class Parent
  include Surrealist

  json_schema do
    { name: String }
  end

  def name
    'Parent'
  end
end

class Child < Parent
  def name
    'Child'
  end
end

If we surrealize Parent, everything is fine:
Parent.new.surrealize # => '{ "name": "Parent" }'
But if we surrealize Child, error is thrown:

Child.new.surrealize
# => Surrealist::UnknownSchemaError: Can't serialize Child - no schema was provided.

I guess it would be useful to have a class method that would delegate surrealization to specified class, something like:

class Child < Parent
  
  delegate_surrealization_to Parent
  
  def name
    'Child'
  end
end
Child.new.surrealize # => '{ "name": "Child" }'
@AlessandroMinali
Copy link
Collaborator

I will take a look at this

@nesaulov
Copy link
Owner Author

nesaulov commented Oct 6, 2017

@AlessandroMinali alright, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants