Module: ActionPolicy::PrettyPrint
- Defined in:
- lib/action_policy/utils/pretty_print.rb
Overview
Takes the object and a method name, and returns the “annotated” source code for the method: code is split into parts by logical operators and each part is evaluated separately.
Example:
class MyClass
def access?
admin? && access_feed?
end
end
puts PrettyPrint.format_method(MyClass.new, :access?)
#=> MyClass#access?
#=> ↳ admin? #=> false
#=> AND
#=> access_feed? #=> true
Defined Under Namespace
Classes: Visitor
Constant Summary collapse
- TRUE =
"\e[32mtrue\e[0m"
- FALSE =
"\e[31mfalse\e[0m"
Class Attribute Summary collapse
-
.ignore_expressions ⇒ Object
Returns the value of attribute ignore_expressions.
Class Method Summary collapse
Instance Method Summary collapse
Class Attribute Details
.ignore_expressions ⇒ Object
Returns the value of attribute ignore_expressions.
127 128 129 |
# File 'lib/action_policy/utils/pretty_print.rb', line 127 def ignore_expressions @ignore_expressions end |
Class Method Details
.colorize(val) ⇒ Object
143 144 145 146 147 148 |
# File 'lib/action_policy/utils/pretty_print.rb', line 143 def colorize(val) return val unless $stdout.isatty return TRUE if val.eql?(true) # rubocop:disable Lint/DeprecatedConstants return FALSE if val.eql?(false) # rubocop:disable Lint/DeprecatedConstants val end |
Instance Method Details
#available? ⇒ Boolean
130 |
# File 'lib/action_policy/utils/pretty_print.rb', line 130 def available?() = true |