nisetegami 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,5 @@
1
1
  module Nisetegami
2
2
  class ApplicationController < ActionController::Base
3
+ protect_from_forgery
3
4
  end
4
5
  end
@@ -2,6 +2,8 @@ require_dependency "nisetegami/application_controller"
2
2
 
3
3
  module Nisetegami
4
4
  class TemplatesController < ApplicationController
5
+ before_filter Nisetegami.auth_filter if Nisetegami.auth_filter
6
+
5
7
  def index
6
8
  @templates = Template.recent
7
9
  params[:enabled] = params[:enabled] == 'true' ? true : false unless params[:enabled].blank?
@@ -4,11 +4,12 @@ Nisetegami.configure do |config|
4
4
  # begin
5
5
  # "#{klass}Decorator".constantize
6
6
  # rescue
7
- # klass.constantize
7
+ # klass
8
8
  # end
9
9
  # end
10
10
 
11
+ # config.auth_filter = -> { redirect_to main_app.root_path unless current_user && current_user.admin? }
12
+
11
13
  # Mailers mapping
12
- # config.register 'UserMailer', :signup, user, temporary_password, created_at: 'DateTime'
13
- # config.register 'UserMailer', :notice, user, notice, additional_attributes: 'Hash'
14
+ # config.register UserMailer, :user, :notice, post: Blog::Post, additional_attributes: Hash
14
15
  end
@@ -22,6 +22,8 @@ module Nisetegami
22
22
  mattr_reader :email_re
23
23
  @@email_re = /[-a-z0-9_+\.]+@([-a-z0-9]+\.)+[a-z0-9]{2,}/
24
24
 
25
+ mattr_accessor :auth_filter
26
+
25
27
  def self.configure
26
28
  yield self
27
29
  end
@@ -30,15 +32,13 @@ module Nisetegami
30
32
  # into a class with liquid_methods
31
33
  def self.cast(&block)
32
34
  @@cast ||= ->(thing) do
33
- if defined?(thing) == 'constant'
34
- thing
35
- elsif const_defined?(thing.to_s)
36
- thing.to_s.constantize
37
- else
35
+ begin
36
+ thing = thing.to_s.constantize
37
+ block_given? ? yield(thing) : thing
38
+ rescue NameError
38
39
  String
39
40
  end
40
41
  end
41
- block_given? ? @@cast = block : @@cast
42
42
  end
43
43
 
44
44
  def self.register(*args)
@@ -1,3 +1,3 @@
1
1
  module Nisetegami
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nisetegami
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: