| 1 | package Fey::Literal; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 28 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 28 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 28 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 28 | our $VERSION = '0.44'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 28 | ▶ | use Fey::FakeDBI; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 28 | ▶ | use Fey::Literal::Function; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 28 | ▶ | use Fey::Literal::Null; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 28 | ▶ | use Fey::Literal::Number; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 28 | ▶ | use Fey::Literal::String; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 28 | ▶ | use Fey::Literal::Term; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 28 | ▶ | use Fey::Types; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 28 | ▶ | use Scalar::Util qw( blessed looks_like_number ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 28 | ▶ | use overload (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | # This needs to come before we load subclasses or shit blows up | ||||||||||||||||||||||||||||
| 20 | # because we end up with a metaclass object that is a | ||||||||||||||||||||||||||||
| 21 | # Class::MOP::Class, not Moose::Meta::Class. | ||||||||||||||||||||||||||||
| 22 | 28 | ▶ | use Moose 2.1200; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 28 | ▶ | use MooseX::SemiAffordanceAccessor 0.03; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 28 | ▶ | use MooseX::StrictConstructor 0.13; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 235 | ▶ | sub new_from_scalar { | ||||||||||||||||||||||||||
|
Subroutine
new_from_scalar: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 27 | 235 | shift; | |||||||||||||||||||||||||||
| 28 | 235 | my $val = shift; | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 235 | ▶ | return Fey::Literal::Null->new() | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | unless defined $val; | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | # Freaking Perl overloading is so broken! An overloaded reference | ||||||||||||||||||||||||||||
| 34 | # will not pass the type constraints, so we need to manually | ||||||||||||||||||||||||||||
| 35 | # convert it to a non-ref. | ||||||||||||||||||||||||||||
| 36 | 224 | ▶ | if ( blessed $val && overload::Overloaded($val) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($val) and overload::Overloaded($val)
MC/DC50%1/2
builtin::blessed($val) and overload::Overloaded($val)
builtin::blessed($val)
overload::Overloaded($val)
Truth table66%2/3
A and B
A= builtin::blessed($val)B= overload::Overloaded($val)
| |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | # The stringification method will be derived from the | ||||||||||||||||||||||||||||
| 39 | # numification method if needed. This might produce strange | ||||||||||||||||||||||||||||
| 40 | # results in the case of something that overloads both | ||||||||||||||||||||||||||||
| 41 | # operations, like a number class that returns either 2 or | ||||||||||||||||||||||||||||
| 42 | # "two", but in that case the author of the class made our | ||||||||||||||||||||||||||||
| 43 | # life impossible anyway ;) | ||||||||||||||||||||||||||||
| 44 | 2 | $val = $val . ''; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 224 | ▶ | return looks_like_number($val) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | ? Fey::Literal::Number->new($val) | ||||||||||||||||||||||||||||
| 49 | : Fey::Literal::String->new($val); | ||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 28 | __PACKAGE__->meta()->make_immutable(); | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 28 | 1; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | # ABSTRACT: Factory for making a literal piece of a SQL statement | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | __END__ | ||||||||||||||||||||||||||||