Sha256: 975977e86dbbacf645cacfb824df9dd9c81131263412197676dd94fad2b3a9cc

Contents?: true

Size: 871 Bytes

Versions: 12

Compression:

Stored size: 871 Bytes

Contents

class Restly::Associations::Base
  extend ActiveSupport::Autoload

  autoload :Loaders
  autoload :Stubs
  autoload :Builders
  autoload :Modifiers
  autoload :Conditionals

  include Loaders
  include Stubs
  include Builders
  include Modifiers
  include Conditionals

  attr_reader :name, :namespace, :polymorphic, :options

  def initialize(owner, name, options={})
    @name = name
    @namespace = options.delete(:namespace) || owner.name.gsub(/(::)?\w+$/, '')
    @polymorphic = options.delete(:polymorphic)
    options[:class_name] ||= name.to_s.classify
    @owner = owner
    @options = options
  end

  def association_class
    [@namespace, options[:class_name]].select(&:present?).join('::').constantize
  end

  private

  def association_resource_name
    collection? ? association_class.resource_name.pluralize : association_class.resource_name
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
restly-0.0.1.beta.6 lib/restly/associations/base.rb
restly-0.0.1.beta.5 lib/restly/associations/base.rb
restly-0.0.1.beta.4 lib/restly/associations/base.rb
restly-0.0.1.beta.3 lib/restly/associations/base.rb
restly-0.0.1.beta.2 lib/restly/associations/base.rb
restly-0.0.1.beta.1 lib/restly/associations/base.rb
restly-0.0.1.alpha.22 lib/restly/associations/base.rb
restly-0.0.1.alpha.19 lib/restly/associations/base.rb
restly-0.0.1.alpha.18 lib/restly/associations/base.rb
restly-0.0.1.alpha.16 lib/restly/associations/base.rb
restly-0.0.1.alpha.12 lib/restly/associations/base.rb
restly-0.0.1.alpha.11 lib/restly/associations/base.rb