Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

smart_methods

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smart_methods

  • 0.0.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

smart_methods

smart_methods helps to define class and instance methods using pretty DSL.

Build Status Gem Version Dependency Status Code Climate

Installation

Add this line to your application's Gemfile:

gem 'smart_methods'

Usage

Working with class methods:

class Source
  extend SmartMethods
  smart_methods :status, :type

  self.status 'undefined'
  self.type 'undefined'
end

class Sms < Source
  self.type 'sms'
end

class Phone < Source
end

Phone.type = 'phone'

Phone.type
# => 'phone'

Sms.type
# => 'sms'

Phone.status
# => "undefined"

Working with instance methods:

class Source
  extend SmartMethods
  smart_methods :status, :type

  status { "new_" + type.to_s }
end

Source.new.type
# => nil

Source.new.status
# => 'new_'

class Sms < Source
  type { 'sms' }
end

Sms.new.type
# => 'sms'

Sms.new.status
# => 'new_sms'

class Phone < Sms
  type { 'phone' }
end

Phone.new.status
# => 'new_phone'

class Email < Sms
end

email = Email.new
email.type = 'email'

email.type
# => 'email'

email.status
# => 'new_email'

Thanks

Sponsored by [Evil Martians]. [Evil Martians]: http://evilmartians.com/

FAQs

Package last updated on 30 Apr 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc