Sha256: 98c77aa100a678f671eff738265d8a2cd59f9e676a8ffeaa083284512a077363

Contents?: true

Size: 712 Bytes

Versions: 15

Compression:

Stored size: 712 Bytes

Contents

class Site::Client < Site
  validates_presence_of :url, :callback_url, :secret

  before_validation :set_secret,
                    on: :create

  after_create :set_admin

  scope :administered_by, lambda { |actor|
    joins(actor: :sent_ties).
      merge(Contact.received_by(actor)).
      merge(Tie.related_by(Relation::Admin.instance))
  }

  %w{ url callback_url secret }.each do |m|
    define_method m do
      config[m]
    end

    define_method "#{ m }=" do |arg|
      config[m] = arg
    end
  end

  def to_param
    id
  end

  private

  def set_secret
    self.secret = SecureRandom.hex(64)
  end

  def set_admin
    contact_to!(author).relation_ids = [ Relation::Admin.instance.id ]
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
social_stream-2.0.4 oauth2_server/app/models/site/client.rb
social_stream-oauth2_server-2.0.3 app/models/site/client.rb
social_stream-2.0.3 oauth2_server/app/models/site/client.rb
social_stream-oauth2_server-2.0.2 app/models/site/client.rb
social_stream-2.0.2 oauth2_server/app/models/site/client.rb
social_stream-oauth2_server-2.0.1 app/models/site/client.rb
social_stream-2.0.1 oauth2_server/app/models/site/client.rb
social_stream-2.0.0 oauth2_server/app/models/site/client.rb
social_stream-oauth2_server-2.0.0 app/models/site/client.rb
social_stream-2.0.0.beta3 oauth2_server/app/models/site/client.rb
social_stream-oauth2_server-2.0.0.beta3 app/models/site/client.rb
social_stream-2.0.0.beta2 oauth2_server/app/models/site/client.rb
social_stream-oauth2_server-2.0.0.beta2 app/models/site/client.rb
social_stream-2.0.0.beta1 oauth2_server/app/models/site/client.rb
social_stream-oauth2_server-2.0.0.beta1 app/models/site/client.rb