Created
October 18, 2018 13:35
-
-
Save jjn1056/c09447fbdf9f86507c860ce9f6dd5a6e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package Adama::Model::Feature; | |
| use strict; | |
| use warnings; | |
| use Adama::Util::LaunchDarkly; | |
| use Moo; | |
| use Catalyst::Utils; | |
| extends 'Catalyst::Model'; | |
| __PACKAGE__->mk_accessors(qw/user/); | |
| sub ACCEPT_CONTEXT { | |
| my ($self, $c ) = @_; | |
| $self = bless({ %$self, | |
| user => $c->user, | |
| }, ref($self)); | |
| return $self; | |
| } | |
| our $FEATURE_CLASS = 'Adama::Util::LaunchDarkly'; | |
| sub enabled { | |
| my ($self, $feature) = @_; | |
| my $user; | |
| if (!$self->user || !$self->user->obj) { | |
| $user = -1 | |
| } else { | |
| $user = $self->user->obj | |
| } | |
| ensure_class_loaded($FEATURE_CLASS); | |
| return $FEATURE_CLASS::feature_enabled($user, $feature); | |
| } | |
| 1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment