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

New Array serializer and changes to existing Json serializer #97

Merged
1 commit merged into from
Dec 5, 2010
Merged

New Array serializer and changes to existing Json serializer #97

1 commit merged into from
Dec 5, 2010

Conversation

ashmckenzie
Copy link

Hi,

I had a requirement to $User->to_array() and $User->attributes() wasn't appropriate in the particular scenario because I wanted to exclude the password attribute and I didn't want to override attributes(), so I override to_array() in User like so: -

class User extends Model

    public function to_array() {

      $options = array(
        'except' => array('password')
      );

      return parent::to_array($options);
    }
}

As the Json and Array serialization code is mostly the same, I made the Json serializer extend the Array serializer. Not sure if that's the best approach, but it made the code more DRY.

Commit - https://github.com/asha79/php-activerecord/commit/b669e413b198aceae03075988e5b9fcfd7338092

Ash.

- added new ArraySerializer Serialization class
- changed JsonSerializer which extends ArraySerializer to dry things up
- added ArraySerializer tests
@kla
Copy link
Collaborator

kla commented Dec 5, 2010

Merged. Thanks for patch.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants