Module: Phrasing

Defined in:
lib/phrasing.rb,
lib/phrasing.rb,
lib/phrasing/version.rb,
lib/phrasing/serializer.rb,
lib/phrasing/implementation.rb

Defined Under Namespace

Modules: Implementation, Rails, Serializer

Constant Summary collapse

WHITELIST =
"PhrasingPhrase.value"
VERSION =
"3.2.6"
@@route =
'phrasing'

Class Method Summary collapse

Class Method Details

.is_whitelisted?(klass, attribute) ⇒ Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/phrasing.rb', line 57

def self.is_whitelisted?(klass,attribute)
  allow_update_on_all_models_and_attributes == true or whitelist.include? "#{klass}.#{attribute}"
end

.logObject



30
31
32
# File 'lib/phrasing.rb', line 30

def self.log
  @@log
end

.log=(log_value) ⇒ Object



34
35
36
37
# File 'lib/phrasing.rb', line 34

def self.log=(log_value)
  @@log = log_value
  suppress_log if log_value == false
end

.setup {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Phrasing)

    the object that the method was called on



39
40
41
# File 'lib/phrasing.rb', line 39

def self.setup
  yield self
end

.suppress_logObject



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/phrasing.rb', line 63

def self.suppress_log
  logger_class = defined?(ActiveSupport::Logger) ? ActiveSupport::Logger::SimpleFormatter : Logger::SimpleFormatter

  logger_class.class_eval do

    alias_method :old_call, :call

    def call(severity, timestamp, progname, msg)
      unless (msg.include? "SELECT" and (msg.include? "phrasing_phrases" or msg.include? "phrasing_phrase_versions"))
        old_call(severity, timestamp, progname, msg)
      end
    end

  end
end

.whitelistObject



45
46
47
48
49
50
51
# File 'lib/phrasing.rb', line 45

def self.whitelist
  if defined? @@whitelist
    @@whitelist + [WHITELIST]
  else
    [WHITELIST]
  end
end

.whitelist=(whitelist) ⇒ Object



53
54
55
# File 'lib/phrasing.rb', line 53

def self.whitelist=(whitelist)
  @@whitelist = whitelist
end