Sha256: c6326b4e7c750b51b8c7aca8e57815ce26705dee9f77a212ce1f32caf9682390

Contents?: true

Size: 878 Bytes

Versions: 13

Compression:

Stored size: 878 Bytes

Contents

require 'has_vcards/railtie' if defined?(::Rails::Railtie)

module HasVcardsClassMethods
  def has_vcards(options = {})
    class_eval <<-end_eval
      scope :by_name, lambda {|name| {:include => :vcard, :order => 'vcards.full_name', :conditions => Vcard.by_name_conditions(name)}}

      has_one :vcard, :as => 'object', :autosave => true, :validate => true
      delegate :full_name, :nickname, :family_name, :given_name, :additional_name, :honorific_prefix, :honorific_suffix, :to => :vcard
      delegate :full_name=, :nickname=, :family_name=, :given_name=, :additional_name=, :honorific_prefix=, :honorific_suffix=, :to => :vcard
      
      has_many :vcards, :as => 'object', :autosave => true, :validate => true

      def vcard_with_autobuild
        vcard_without_autobuild || build_vcard
      end
      alias_method_chain :vcard, :autobuild
    end_eval
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
has_vcards-0.20.3 lib/has_vcards.rb
has_vcards-0.20.2 lib/has_vcards.rb
has_vcards-0.20.1 lib/has_vcards.rb
has_vcards-0.20.0 lib/has_vcards.rb
has_vcards-0.19.0 lib/has_vcards.rb
has_vcards-0.18.0 lib/has_vcards.rb
has_vcards-0.17.2 lib/has_vcards.rb
has_vcards-0.17.1 lib/has_vcards.rb
has_vcards-0.17.0 lib/has_vcards.rb
has_vcards-0.16.0 lib/has_vcards.rb
has_vcards-0.15.0 lib/has_vcards.rb
has_vcards-0.14.1 lib/has_vcards.rb
has_vcards-0.14.0 lib/has_vcards.rb