Top Level Namespace
Defined Under Namespace
Modules: PUNK, Rack, Sequel, SpecHelpers Classes: Hash, Roda, SwaggerOnHandler, SwaggerRouteHandler
Instance Method Summary collapse
- #_groups ⇒ Object
- #_groups_users ⇒ Object
- #_identities ⇒ Object
- #_sessions ⇒ Object
- #_tenants ⇒ Object
- #_tenants_users ⇒ Object
- #_users ⇒ Object
- #perform(action_class, **kwargs) ⇒ Object
- #present(view_class, **kwargs) ⇒ Object
- #reload! ⇒ Object
- #run(service_class, **kwargs) ⇒ Object
Instance Method Details
#_groups ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/punk/migrations/001_punk.rb', line 38 def _groups create_table :groups do uuid :id, primary_key: true, default: Sequel.function(:gen_random_uuid) punk_state :state, null: false, default: "created" String :name, null: false, text: true String :icon, text: true jsonb :data, default: "{}" DateTime :created_at DateTime :updated_at foreign_key :tenant_id, :tenants, null: false, type: :uuid end end |
#_groups_users ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/punk/migrations/001_punk.rb', line 51 def _groups_users create_table :groups_users do primary_key [:group_id, :user_id] foreign_key :group_id, :groups, null: false, type: :uuid foreign_key :user_id, :users, null: false, type: :uuid index [:group_id, :user_id] end end |
#_identities ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/punk/migrations/001_punk.rb', line 60 def _identities create_enum(:claim_type, %w[email phone]) create_table :identities do uuid :id, primary_key: true, default: Sequel.function(:gen_random_uuid) punk_state :state, null: false, default: "created" claim_type :claim_type, null: false String :claim, text: true, null: false, unique: true jsonb :data, default: "{}" DateTime :created_at DateTime :updated_at foreign_key :user_id, :users, null: true, type: :uuid end end |
#_sessions ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/punk/migrations/001_punk.rb', line 74 def _sessions create_enum(:session_state, %w[pending created active deleted expired]) create_table :sessions do uuid :id, primary_key: true, default: Sequel.function(:gen_random_uuid) uuid :slug, default: Sequel.function(:gen_random_uuid) session_state :state, null: false, default: "created" File :salt, text: true File :hash, text: true Integer :attempt_count, null: false, default: 0 cidr :remote_addr, null: false, default: "127.0.0.1" String :user_agent, text: true, null: false, default: "Mozilla/5.0 (compatible; Punk!; +https://punk.kranzky.com)" jsonb :data, default: "{}" DateTime :created_at DateTime :updated_at foreign_key :identity_id, :identities, null: false, type: :uuid end end |
#_tenants ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/punk/migrations/001_punk.rb', line 3 def _tenants create_table :tenants do uuid :id, primary_key: true, default: Sequel.function(:gen_random_uuid) punk_state :state, null: false, default: "created" String :name, null: false, text: true String :icon, text: true jsonb :data, default: "{}" DateTime :created_at DateTime :updated_at end end |
#_tenants_users ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/punk/migrations/001_punk.rb', line 29 def _tenants_users create_table :tenants_users do primary_key [:tenant_id, :user_id] foreign_key :tenant_id, :tenants, null: false, type: :uuid foreign_key :user_id, :users, null: false, type: :uuid index [:tenant_id, :user_id] end end |
#_users ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/punk/migrations/001_punk.rb', line 15 def _users create_table :users do uuid :id, primary_key: true, default: Sequel.function(:gen_random_uuid) punk_state :state, null: false, default: "created" String :name, null: false, text: true String :icon, text: true String :email, text: true, unique: true String :phone, text: true, unique: true jsonb :data, default: "{}" DateTime :created_at DateTime :updated_at end end |
#perform(action_class, **kwargs) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/punk/core/pry.rb', line 3 def perform(action_class, **kwargs) raise PUNK::InternalServerError, "Not an action: #{action_class}" unless action_class < PUNK::Action action_class.perform(**kwargs) ensure SemanticLogger.flush end |
#present(view_class, **kwargs) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/punk/core/pry.rb', line 10 def present(view_class, **kwargs) raise PUNK::InternalServerError, "Not a view: #{view_class}" unless view_class < PUNK::View view_class.present(**kwargs) ensure SemanticLogger.flush end |
#reload! ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/punk/core/pry.rb', line 24 def reload! ["actions", "models", "views", "services", "workers"].each do |dir| path = File.join(PUNK.get.app.path, dir) Dir.glob(File.join(path, "**/*.rb")).each { |file| load(file) } end "Reloaded all actions, models, views, services and workers." ensure SemanticLogger.flush end |
#run(service_class, **kwargs) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/punk/core/pry.rb', line 17 def run(service_class, **kwargs) raise PUNK::InternalServerError, "Not a service: #{service_class}" unless service_class.superclass == PUNK::Service service_class.run(**kwargs).result ensure SemanticLogger.flush end |