🚀 Socket Launch Week 🚀 Day 5: Introducing Socket Fix.Learn More
Socket
Sign inDemoInstall
Socket

scope_composer

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scope_composer

0.4.3
Rubygems
Version published
Maintainers
1
Created
Source

ScopeComposer

class Example

  include ScopeComposer::Model

  scope_composer_for :search

  search_helper :integer, ->(v){ v.to_s.to_i }

  search_scope :limit
  search_scope :offset, ->(i){ where(offset: integer(i) ) }

  search_helper :find, ->(id){ Example.where(self.attributes).find(id) }

  def self.where(attrs)
    puts "where: #{attrs.to_param}"
    self
  end

  def self.find(id)
    puts "find by #{id}"
    self.new
  end

end

Example.limit(10).offset('50').find(10)
Example.limit(10).offset('50').to_param

scope = Example.limit(10)
scope.offset(20)
scope.find(2)

where: limit=10&offset=50
find by 10
Example:0x007ff8eb8ce920

FAQs

Package last updated on 31 Oct 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts