Sha256: f15b5be53c0121804a5745ec4bd3b2247235367edf42af98593a2369009eedff

Contents?: true

Size: 774 Bytes

Versions: 1

Compression:

Stored size: 774 Bytes

Contents

require 'ninsho/authentication'

module Ninsho
  module Interface
    def self.included(base)
      base.extend(ClassMethods)
    end

    module ClassMethods
      
      def belongs_to_ninsho(*args)
        options = args.extract_options!
        
        associations = args.collect(&:to_s).collect(&:downcase)
        association_keys = associations.collect { |association| "#{association}_id" } 

        #Set the belongs_to association by ActiveRecord
        associations.each do |associated_model|
          belongs_to associated_model.to_sym
          Ninsho.parent_resource_name = Ninsho.ref(associated_model.to_s.classify).get
        end
      end

      def from_omniauth(omniauth = nil)
        Ninsho::Authentication.new(omniauth)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ninsho-0.0.1 lib/ninsho/interface.rb