I hereby claim:
- I am kkempin on github.
- I am kkempin (https://keybase.io/kkempin) on keybase.
- I have a public key ASAfqUYq60qPCxPSOI7VSgGHD9_fsS7p1W9MSSaG701Cowo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
<style> | |
.mobile-channel-template.survey.zl-container {font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;max-width:400px;margin:0 auto;} | |
.mobile-channel-template.survey .m-r-2 {margin-right:20px;} | |
.mobile-channel-template.survey .m-t-2 {margin-top:20px;} | |
.mobile-channel-template.survey {padding:90px 15px 15px 15px;} | |
.mobile-channel-template.survey .question {color:#0e1116;font-size:15px;font-weight:600;line-height:1.4;white-space:pre-line;word-break:break-word;} | |
.mobile-channel-template.survey .comment-question {margin-top:20px;margin-bottom:15px;} | |
.mobile-channel-template.survey ul {overflow:hidden;margin:0;padding:0;display:inline-block;} | |
.mobile-channel-template.survey ul li {display:inline-block;float:left;} | |
.mobile-channel-template.survey label {text-decoration:none;text-align:center;color:#555;display:block;font-weight:600;border-radius:100%;border:3px solid #c1c1c1;height:36px;width:36px;line-height:30px;box-sizing:border-box;margin-bottom:0;} |
import UserBuilder | |
user = build() | |
|> name("John", "Doe") | |
|> birthday(1999, 3, 2) | |
|> set_as_on_hold | |
|> men | |
|> admin | |
|> login_credentials("test@test.com", "abcdef") |
defmodule UserBuilder do | |
def build, do: %User{} | |
def name(user, first_name, last_name), | |
do: %{user | first_name: first_name, last_name: last_name} | |
def birthday(user, year, month, day) | |
when is_integer(year) and is_integer(month) and is_integer(day) do | |
case Date.new(year, month, day) do | |
{:ok, date} -> %{user | birthday: date} |
%User{ | |
first_name: "John", | |
last_name: "Doe", | |
birthday: ~D[1999-03-02], | |
email: "test@test.com", | |
gender: "m", | |
password: "abcdef", | |
roles: ["admin"], | |
status: "on_hold" | |
} |
defmodule User do | |
defstruct first_name: nil, last_name: nil, birthday: nil, gender: nil, | |
roles: [], status: nil, email: nil, password: nil | |
end |
user = User.new('admin') | |
policy = LogsControllerPolicy.new( | |
ProfileControllerPolicy.new( | |
RegistrationControllerPolicy.new() | |
) | |
) | |
puts policy.check_access(ProfileController, user) |
class RegistrationControllerPolicy < Policy | |
def process_checking_access(controller, user) | |
user.role == 'guest' | |
end | |
end | |
class ProfileControllerPolicy < Policy | |
def process_checking_access(controller, user) | |
['internal_user', 'admin'].include?(user.role) | |
end |
class Policy | |
attr_reader :successor | |
def initialize(successor=nil) | |
@successor = successor | |
end | |
def check_access(controller, user) | |
if policy_matches_controller?(controller) | |
return process_checking_access(controller, user) |
class User | |
# possible roles: guest, internal_user, admin | |
attr_reader :role | |
def initialize(role) | |
@role = role | |
end | |
end | |
class RegistrationController; end |