summaryrefslogtreecommitdiff
path: root/lib/GitHub/Collector/Role/Graph/Query.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/GitHub/Collector/Role/Graph/Query.pm')
-rw-r--r--lib/GitHub/Collector/Role/Graph/Query.pm45
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/GitHub/Collector/Role/Graph/Query.pm b/lib/GitHub/Collector/Role/Graph/Query.pm
new file mode 100644
index 0000000..d3ab7f0
--- /dev/null
+++ b/lib/GitHub/Collector/Role/Graph/Query.pm
@@ -0,0 +1,45 @@
+package GitHub::Collector::Role::Graph::Query;
+
+use Moose::Role;
+
+has language => (
+ is => 'rw',
+ isa => 'Str',
+ predicate => 'has_language',
+);
+
+has location => (
+ is => 'rw',
+ isa => 'Str',
+ predicate => 'has_location',
+);
+
+has company => (
+ is => 'ro',
+ isa => 'Str',
+ predicate => 'has_company',
+);
+
+has country => (
+ is => 'ro',
+ isa => 'Str',
+ predicate => 'has_country',
+);
+
+
+sub build_query {
+ my $self = shift;
+
+ my $search = {};
+
+ foreach my $attr (qw/language location company country/) {
+ my $predicate = "has_$attr";
+ if ( $self->$predicate ) {
+ $search->{$attr} = $self->$attr;
+ }
+ }
+
+ return $search;
+}
+
+1;