Skip to content

Instantly share code, notes, and snippets.

@jjn1056
Created October 18, 2018 13:35
Show Gist options
  • Select an option

  • Save jjn1056/c09447fbdf9f86507c860ce9f6dd5a6e to your computer and use it in GitHub Desktop.

Select an option

Save jjn1056/c09447fbdf9f86507c860ce9f6dd5a6e to your computer and use it in GitHub Desktop.
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