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.3.17 lib/flydata/heroku/configuration_methods.rb
flydata-0.3.16 lib/flydata/heroku/configuration_methods.rb
flydata-0.3.15 lib/flydata/heroku/configuration_methods.rb
flydata-0.3.14 lib/flydata/heroku/configuration_methods.rb
flydata-0.3.13 lib/flydata/heroku/configuration_methods.rb
flydata-0.3.12 lib/flydata/heroku/configuration_methods.rb
flydata-0.3.11 lib/flydata/heroku/configuration_methods.rb
flydata-0.3.10 lib/flydata/heroku/configuration_methods.rb
flydata-0.3.9 lib/flydata/heroku/configuration_methods.rb
flydata-0.3.8 lib/flydata/heroku/configuration_methods.rb
flydata-0.3.7 lib/flydata/heroku/configuration_methods.rb
flydata-0.3.6 lib/flydata/heroku/configuration_methods.rb
flydata-0.3.5 lib/flydata/heroku/configuration_methods.rb
flydata-0.3.4 lib/flydata/heroku/configuration_methods.rb
flydata-0.3.3 lib/flydata/heroku/configuration_methods.rb
flydata-0.3.2 lib/flydata/heroku/configuration_methods.rb
flydata-0.3.1 lib/flydata/heroku/configuration_methods.rb
flydata-0.3.0 lib/flydata/heroku/configuration_methods.rb
flydata-0.2.30 lib/flydata/heroku/configuration_methods.rb
flydata-0.2.29 lib/flydata/heroku/configuration_methods.rb