Sha256: 569f215fef9f6fd275a9cfd784964f58515b2d54ef573a4354c355a460a35819

Contents?: true

Size: 828 Bytes

Versions: 2

Compression:

Stored size: 828 Bytes

Contents

module Inkwell
  module Common
    def is_comment(obj)
      post_class = Object.const_get ::Inkwell::Engine::config.post_table.to_s.singularize.capitalize
      case obj
        when ::Inkwell::Comment
          is_comment = true
        when post_class
          is_comment = false
        else
          raise "obj should be Comment or #{post_class.class}"
      end
      is_comment
    end

    def check_user(obj)
      user_class = Object.const_get ::Inkwell::Engine::config.user_table.to_s.singularize.capitalize
      raise "user should be a #{user_class.to_s}" unless obj.is_a? user_class
    end

    def check_post(obj)
      post_class = Object.const_get ::Inkwell::Engine::config.post_table.to_s.singularize.capitalize
      raise "post should be a #{user_class.to_s}" unless obj.is_a? post_class
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
inkwell-1.0.5 lib/common/base.rb
inkwell-1.0.4 lib/common/base.rb