Sha256: 3111a013110153f4400fdf008af1de7172f4cedb60d4d3c8b5792045f028b655

Contents?: true

Size: 1.39 KB

Versions: 149

Compression:

Stored size: 1.39 KB

Contents

module Flydata
  module Heroku
    module ConfigurationMethods
      extend ActiveSupport::Concern

      included do
        if respond_to?(:class_attribute)
          class_attribute :_flydata_table_name
          class_attribute :_flydata_attributes
        else
          class_inheritable_accessor :_flydata_table_name
          class_inheritable_accessor :_flydata_attributes
        end
        self._flydata_table_name = nil
        self._flydata_attributes = nil
      end

      module ClassMethods
        # @example
        #   class User < ActiveRecord::Base
        #     flydata_attr :id, :name
        #   end
        def flydata_attr(*attributes)
          raise "flydata_attr attributes cannot be blank" if attributes.empty?
          self._flydata_attributes = attributes.map(&:to_sym)
        end

        # @example
        #   class User < ActiveRecord::Base
        #     flydata_table :other_table
        #   end
        def flydata_table(table_name)
          self._flydata_table_name = table_name
        end

        # @return [String]
        def flydata_table_name
          self._flydata_table_name ||= if self.ancestors.include?(ActiveRecord::Base)
                                         self.table_name
                                       else
                                         self.name.tableize
                                       end
        end
      end
    end
  end
end

Version data entries

149 entries across 149 versions & 1 rubygems

Version Path
flydata-0.8.10.2 lib/flydata/heroku/configuration_methods.rb
flydata-0.8.10.1 lib/flydata/heroku/configuration_methods.rb
flydata-0.8.9.11 lib/flydata/heroku/configuration_methods.rb
flydata-0.8.10 lib/flydata/heroku/configuration_methods.rb
flydata-0.8.9 lib/flydata/heroku/configuration_methods.rb
flydata-0.8.8 lib/flydata/heroku/configuration_methods.rb
flydata-0.8.7 lib/flydata/heroku/configuration_methods.rb
flydata-0.8.6 lib/flydata/heroku/configuration_methods.rb
flydata-0.8.5 lib/flydata/heroku/configuration_methods.rb
flydata-0.8.4 lib/flydata/heroku/configuration_methods.rb
flydata-0.8.3 lib/flydata/heroku/configuration_methods.rb
flydata-0.8.2 lib/flydata/heroku/configuration_methods.rb
flydata-0.8.1 lib/flydata/heroku/configuration_methods.rb
flydata-0.8.0 lib/flydata/heroku/configuration_methods.rb
flydata-0.7.19 lib/flydata/heroku/configuration_methods.rb
flydata-0.7.18 lib/flydata/heroku/configuration_methods.rb
flydata-0.7.17 lib/flydata/heroku/configuration_methods.rb
flydata-0.7.16 lib/flydata/heroku/configuration_methods.rb
flydata-0.7.15 lib/flydata/heroku/configuration_methods.rb
flydata-0.7.14 lib/flydata/heroku/configuration_methods.rb