SlideShare a Scribd company logo
@vinothiniBJ
Active Support Improvements
– Rails5
©2014
• https://goo.gl/ZTl8oO
• prev_day
• next_day
• on_weekend
• on_weekday
• next_weekday
• prev_weekday
• prev_week(same_time: true)
• next_week(same_time: true)
Improvements in Date, Time and DateTime
©2014
• days_in_year
class Time
include DateAndTime::Calculations
COMMON_YEAR_DAYS_IN_MONTH = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
class << self
# Returns the number of days in the given month.
# If no year is specified, it will use the current year.
def days_in_month(month, year = current.year)
if month == 2 && ::Date.gregorian_leap?(year)
29
else
COMMON_YEAR_DAYS_IN_MONTH[month]
end
end
# Returns the number of days in the given year.
# If no year is specified, it will use the current year.
def days_in_year(year = current.year)
days_in_month(2, year) + 337
end
end
end
Improvements in Date, Time and DateTime
©2014
• Pluck ( https://goo.gl/yjuBki )
module Enumerable
# Convert an enumerable to an array based on the given key.
#
# [{ name: "David" }, { name: "Rafael" }, { name: "Aaron" }].pluck(:name)
# => ["David", "Rafael", "Aaron"]
#
# [{ id: 1, name: "David" }, { id: 2, name: "Rafael" }].pluck(:id, :name)
# => [[1, "David"], [2, "Rafael"]]
def pluck(*keys)
if keys.many?
map { |element| keys.map { |key| element[key] } }
else
map { |element| element[keys.first] }
end
end
end
©2014
• Without ( https://goo.gl/etJN7h )
class Array
# Returns a copy of the Array without the specified elements.
#
# people = ["David", "Rafael", "Aaron", "Todd"]
# people.without "Aaron", "Todd"
# => ["David", "Rafael"]
#
# Note: This is an optimization of `Enumerable#without` that uses `Array#-`
# instead of `Array#reject` for performance reasons.
def without(*elements)
self - elements
end
end
©2014
• second_to_last (https://goo.gl/Ig0pOY )
• third_to_last
class Array
# Equal to <tt>self[-3]</tt>.
#
# %w( a b c d e ).third_to_last # => "c"
def third_to_last
self[-3]
end
# Equal to <tt>self[-2]</tt>.
#
# %w( a b c d e ).second_to_last # => "d"
def second_to_last
self[-2]
end
end
©2014
• positive? (https://goo.gl/UsTnWl )
• negative?
class Integer
# Returns true if the number is positive.
#
# 1.positive? # => true
# 0.positive? # => false
# -1.positive? # => false
def positive?
self > 0
end
# Returns true if the number is negative.
#
# -1.positive? # => true
# 0.positive? # => false
# 1.positive? # => false
def negative?
self < 0
end
end
©2014
• Inquiry ( https://goo.gl/47bjv7 , https://goo.gl/QpVmU3 )
class ArrayInquirer < Array
def any?(*candidates, &block)
if candidates.none?
super
else
candidates.any? do |candidate|
include?(candidate) || include?(candidate.to_sym)
end
end
end
private
def respond_to_missing?(name, include_private = false)
name[-1] == '?'
end
def method_missing(name, *args)
if name[-1] == '?'
any?(name[0..-2])
else
super
end
end
end
©2014
Q&A ?
Question and Answers
©2014
WE
BUILD
APPS
THAT
PEOPLE
LOVE TO
USE
Enterprise Web Applications
Development
Cross-Platform Business Mobile
Apps Development
Social Media Integrated
Applications Development
Product Development Services

More Related Content

Viewers also liked

Soal konsep geo
Soal konsep geoSoal konsep geo
Soal konsep geo
Chacha Meirissa
 
Campus Assessment Solution And Importance
Campus Assessment Solution And Importance   Campus Assessment Solution And Importance
Campus Assessment Solution And Importance
Youth4work.com
 
Inner Harmony through Mindfulness Meditation by Gustavo Estrada
Inner Harmony through Mindfulness Meditation by Gustavo EstradaInner Harmony through Mindfulness Meditation by Gustavo Estrada
Inner Harmony through Mindfulness Meditation by Gustavo Estrada
Gustavo Estrada
 
World Tour Keynote Presentation - London
World Tour Keynote Presentation - LondonWorld Tour Keynote Presentation - London
World Tour Keynote Presentation - London
Return Path
 
Currrency Trading Tips & News
Currrency Trading Tips & NewsCurrrency Trading Tips & News
Currrency Trading Tips & News
Nisha Sharma
 
Product Catalog
Product CatalogProduct Catalog
Product CatalogJack Lee
 
#Anchor #comedian #Host #CharacterArtist
#Anchor  #comedian #Host #CharacterArtist #Anchor  #comedian #Host #CharacterArtist
#Anchor #comedian #Host #CharacterArtist
Anchor Rohit Thakur
 
Return Path World Tour Keynote - San Francisco
Return Path World Tour Keynote - San FranciscoReturn Path World Tour Keynote - San Francisco
Return Path World Tour Keynote - San Francisco
Return Path
 
Kelas x perkenalan ilmu geografi
Kelas x perkenalan ilmu geografiKelas x perkenalan ilmu geografi
Kelas x perkenalan ilmu geografi
Chacha Meirissa
 
Cloud computing disadvantages
Cloud computing disadvantagesCloud computing disadvantages
Cloud computing disadvantages
Muhammad Zubair
 
1 dicembre 2015 Certaldo
1 dicembre 2015 Certaldo 1 dicembre 2015 Certaldo
1 dicembre 2015 Certaldo
Barbara Barsanti
 
Scrivere di Protezione Civile
Scrivere di Protezione CivileScrivere di Protezione Civile
Scrivere di Protezione Civile
Barbara Barsanti
 
Piano comunale di emergenza Comune di Montignoso
Piano comunale di emergenza Comune di MontignosoPiano comunale di emergenza Comune di Montignoso
Piano comunale di emergenza Comune di MontignosoBarbara Barsanti
 
Hiv
HivHiv
Boosting Skilling Performance - Solutions for Training Institutes Skill India
Boosting Skilling Performance - Solutions for Training Institutes Skill IndiaBoosting Skilling Performance - Solutions for Training Institutes Skill India
Boosting Skilling Performance - Solutions for Training Institutes Skill India
Youth4work.com
 

Viewers also liked (20)

Diary template
Diary templateDiary template
Diary template
 
Soal konsep geo
Soal konsep geoSoal konsep geo
Soal konsep geo
 
Campus Assessment Solution And Importance
Campus Assessment Solution And Importance   Campus Assessment Solution And Importance
Campus Assessment Solution And Importance
 
Inner Harmony through Mindfulness Meditation by Gustavo Estrada
Inner Harmony through Mindfulness Meditation by Gustavo EstradaInner Harmony through Mindfulness Meditation by Gustavo Estrada
Inner Harmony through Mindfulness Meditation by Gustavo Estrada
 
World Tour Keynote Presentation - London
World Tour Keynote Presentation - LondonWorld Tour Keynote Presentation - London
World Tour Keynote Presentation - London
 
Currrency Trading Tips & News
Currrency Trading Tips & NewsCurrrency Trading Tips & News
Currrency Trading Tips & News
 
During my meditation
During my meditationDuring my meditation
During my meditation
 
M01.JNB.000159_EC 6 Schools Marketing Project Reference
M01.JNB.000159_EC 6 Schools Marketing Project ReferenceM01.JNB.000159_EC 6 Schools Marketing Project Reference
M01.JNB.000159_EC 6 Schools Marketing Project Reference
 
AMN:Addendum
AMN:AddendumAMN:Addendum
AMN:Addendum
 
Product Catalog
Product CatalogProduct Catalog
Product Catalog
 
#Anchor #comedian #Host #CharacterArtist
#Anchor  #comedian #Host #CharacterArtist #Anchor  #comedian #Host #CharacterArtist
#Anchor #comedian #Host #CharacterArtist
 
Return Path World Tour Keynote - San Francisco
Return Path World Tour Keynote - San FranciscoReturn Path World Tour Keynote - San Francisco
Return Path World Tour Keynote - San Francisco
 
Kelas x perkenalan ilmu geografi
Kelas x perkenalan ilmu geografiKelas x perkenalan ilmu geografi
Kelas x perkenalan ilmu geografi
 
Construyendo la web semantica
Construyendo la web semanticaConstruyendo la web semantica
Construyendo la web semantica
 
Cloud computing disadvantages
Cloud computing disadvantagesCloud computing disadvantages
Cloud computing disadvantages
 
1 dicembre 2015 Certaldo
1 dicembre 2015 Certaldo 1 dicembre 2015 Certaldo
1 dicembre 2015 Certaldo
 
Scrivere di Protezione Civile
Scrivere di Protezione CivileScrivere di Protezione Civile
Scrivere di Protezione Civile
 
Piano comunale di emergenza Comune di Montignoso
Piano comunale di emergenza Comune di MontignosoPiano comunale di emergenza Comune di Montignoso
Piano comunale di emergenza Comune di Montignoso
 
Hiv
HivHiv
Hiv
 
Boosting Skilling Performance - Solutions for Training Institutes Skill India
Boosting Skilling Performance - Solutions for Training Institutes Skill IndiaBoosting Skilling Performance - Solutions for Training Institutes Skill India
Boosting Skilling Performance - Solutions for Training Institutes Skill India
 

Similar to Active Support Improvements in Rails 5

Ranges calendar-novosibirsk-2015-08
Ranges calendar-novosibirsk-2015-08Ranges calendar-novosibirsk-2015-08
Ranges calendar-novosibirsk-2015-08
Platonov Sergey
 
FluentMigrator - Dayton .NET - July 2023
FluentMigrator - Dayton .NET - July 2023FluentMigrator - Dayton .NET - July 2023
FluentMigrator - Dayton .NET - July 2023
Matthew Groves
 
The machine learning process: From ideation to deployment with Azure Machine ...
The machine learning process: From ideation to deployment with Azure Machine ...The machine learning process: From ideation to deployment with Azure Machine ...
The machine learning process: From ideation to deployment with Azure Machine ...
Francesca Lazzeri, PhD
 
C programming & data structure [arrays & pointers]
C programming & data structure   [arrays & pointers]C programming & data structure   [arrays & pointers]
C programming & data structure [arrays & pointers]MomenMostafa
 
Rethinking metrics: metrics 2.0 @ Lisa 2014
Rethinking metrics: metrics 2.0 @ Lisa 2014Rethinking metrics: metrics 2.0 @ Lisa 2014
Rethinking metrics: metrics 2.0 @ Lisa 2014
Dieter Plaetinck
 
A3 sec -_regular_expressions
A3 sec -_regular_expressionsA3 sec -_regular_expressions
A3 sec -_regular_expressionsa3sec
 
TSQL Functions (SQL Server)
TSQL Functions (SQL Server)TSQL Functions (SQL Server)
TSQL Functions (SQL Server)
Steve Stedman
 
Google: Drive, Documents and Apps Script - How to work efficiently and happily
Google:  Drive, Documents  and Apps Script - How to work efficiently and happilyGoogle:  Drive, Documents  and Apps Script - How to work efficiently and happily
Google: Drive, Documents and Apps Script - How to work efficiently and happily
Alessandra Santi
 
Architecture for scalable Angular applications
Architecture for scalable Angular applicationsArchitecture for scalable Angular applications
Architecture for scalable Angular applications
Paweł Żurowski
 
Very basic functional design patterns
Very basic functional design patternsVery basic functional design patterns
Very basic functional design patterns
Tomasz Kowal
 
Mapping Online Publics (Part 2)
Mapping Online Publics (Part 2)Mapping Online Publics (Part 2)
Mapping Online Publics (Part 2)
Axel Bruns
 
Football graph - Neo4j and the Premier League
Football graph - Neo4j and the Premier LeagueFootball graph - Neo4j and the Premier League
Football graph - Neo4j and the Premier LeagueMark Needham
 
Method::Signatures
Method::SignaturesMethod::Signatures
Method::Signatures
Michael Schwern
 
Building Single-Page Web Appplications in dart - Devoxx France 2013
Building Single-Page Web Appplications in dart - Devoxx France 2013Building Single-Page Web Appplications in dart - Devoxx France 2013
Building Single-Page Web Appplications in dart - Devoxx France 2013yohanbeschi
 
Effective Application State Management (@DevCamp2017)
Effective Application State Management (@DevCamp2017)Effective Application State Management (@DevCamp2017)
Effective Application State Management (@DevCamp2017)
Oliver Häger
 
How to not blow up spaceships
How to not blow up spaceshipsHow to not blow up spaceships
How to not blow up spaceships
Sabin Marcu
 
Digital analytics with R - Sydney Users of R Forum - May 2015
Digital analytics with R - Sydney Users of R Forum - May 2015Digital analytics with R - Sydney Users of R Forum - May 2015
Digital analytics with R - Sydney Users of R Forum - May 2015
Johann de Boer
 
The Future of Sharding
The Future of ShardingThe Future of Sharding
The Future of Sharding
EDB
 

Similar to Active Support Improvements in Rails 5 (20)

Ranges calendar-novosibirsk-2015-08
Ranges calendar-novosibirsk-2015-08Ranges calendar-novosibirsk-2015-08
Ranges calendar-novosibirsk-2015-08
 
FluentMigrator - Dayton .NET - July 2023
FluentMigrator - Dayton .NET - July 2023FluentMigrator - Dayton .NET - July 2023
FluentMigrator - Dayton .NET - July 2023
 
The machine learning process: From ideation to deployment with Azure Machine ...
The machine learning process: From ideation to deployment with Azure Machine ...The machine learning process: From ideation to deployment with Azure Machine ...
The machine learning process: From ideation to deployment with Azure Machine ...
 
C programming & data structure [arrays & pointers]
C programming & data structure   [arrays & pointers]C programming & data structure   [arrays & pointers]
C programming & data structure [arrays & pointers]
 
Rethinking metrics: metrics 2.0 @ Lisa 2014
Rethinking metrics: metrics 2.0 @ Lisa 2014Rethinking metrics: metrics 2.0 @ Lisa 2014
Rethinking metrics: metrics 2.0 @ Lisa 2014
 
A3 sec -_regular_expressions
A3 sec -_regular_expressionsA3 sec -_regular_expressions
A3 sec -_regular_expressions
 
TSQL Functions (SQL Server)
TSQL Functions (SQL Server)TSQL Functions (SQL Server)
TSQL Functions (SQL Server)
 
Google: Drive, Documents and Apps Script - How to work efficiently and happily
Google:  Drive, Documents  and Apps Script - How to work efficiently and happilyGoogle:  Drive, Documents  and Apps Script - How to work efficiently and happily
Google: Drive, Documents and Apps Script - How to work efficiently and happily
 
Python lecture 05
Python lecture 05Python lecture 05
Python lecture 05
 
Architecture for scalable Angular applications
Architecture for scalable Angular applicationsArchitecture for scalable Angular applications
Architecture for scalable Angular applications
 
Sets in python
Sets in pythonSets in python
Sets in python
 
Very basic functional design patterns
Very basic functional design patternsVery basic functional design patterns
Very basic functional design patterns
 
Mapping Online Publics (Part 2)
Mapping Online Publics (Part 2)Mapping Online Publics (Part 2)
Mapping Online Publics (Part 2)
 
Football graph - Neo4j and the Premier League
Football graph - Neo4j and the Premier LeagueFootball graph - Neo4j and the Premier League
Football graph - Neo4j and the Premier League
 
Method::Signatures
Method::SignaturesMethod::Signatures
Method::Signatures
 
Building Single-Page Web Appplications in dart - Devoxx France 2013
Building Single-Page Web Appplications in dart - Devoxx France 2013Building Single-Page Web Appplications in dart - Devoxx France 2013
Building Single-Page Web Appplications in dart - Devoxx France 2013
 
Effective Application State Management (@DevCamp2017)
Effective Application State Management (@DevCamp2017)Effective Application State Management (@DevCamp2017)
Effective Application State Management (@DevCamp2017)
 
How to not blow up spaceships
How to not blow up spaceshipsHow to not blow up spaceships
How to not blow up spaceships
 
Digital analytics with R - Sydney Users of R Forum - May 2015
Digital analytics with R - Sydney Users of R Forum - May 2015Digital analytics with R - Sydney Users of R Forum - May 2015
Digital analytics with R - Sydney Users of R Forum - May 2015
 
The Future of Sharding
The Future of ShardingThe Future of Sharding
The Future of Sharding
 

Recently uploaded

National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 

Recently uploaded (20)

National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 

Active Support Improvements in Rails 5

  • 2. ©2014 • https://goo.gl/ZTl8oO • prev_day • next_day • on_weekend • on_weekday • next_weekday • prev_weekday • prev_week(same_time: true) • next_week(same_time: true) Improvements in Date, Time and DateTime
  • 3. ©2014 • days_in_year class Time include DateAndTime::Calculations COMMON_YEAR_DAYS_IN_MONTH = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] class << self # Returns the number of days in the given month. # If no year is specified, it will use the current year. def days_in_month(month, year = current.year) if month == 2 && ::Date.gregorian_leap?(year) 29 else COMMON_YEAR_DAYS_IN_MONTH[month] end end # Returns the number of days in the given year. # If no year is specified, it will use the current year. def days_in_year(year = current.year) days_in_month(2, year) + 337 end end end Improvements in Date, Time and DateTime
  • 4. ©2014 • Pluck ( https://goo.gl/yjuBki ) module Enumerable # Convert an enumerable to an array based on the given key. # # [{ name: "David" }, { name: "Rafael" }, { name: "Aaron" }].pluck(:name) # => ["David", "Rafael", "Aaron"] # # [{ id: 1, name: "David" }, { id: 2, name: "Rafael" }].pluck(:id, :name) # => [[1, "David"], [2, "Rafael"]] def pluck(*keys) if keys.many? map { |element| keys.map { |key| element[key] } } else map { |element| element[keys.first] } end end end
  • 5. ©2014 • Without ( https://goo.gl/etJN7h ) class Array # Returns a copy of the Array without the specified elements. # # people = ["David", "Rafael", "Aaron", "Todd"] # people.without "Aaron", "Todd" # => ["David", "Rafael"] # # Note: This is an optimization of `Enumerable#without` that uses `Array#-` # instead of `Array#reject` for performance reasons. def without(*elements) self - elements end end
  • 6. ©2014 • second_to_last (https://goo.gl/Ig0pOY ) • third_to_last class Array # Equal to <tt>self[-3]</tt>. # # %w( a b c d e ).third_to_last # => "c" def third_to_last self[-3] end # Equal to <tt>self[-2]</tt>. # # %w( a b c d e ).second_to_last # => "d" def second_to_last self[-2] end end
  • 7. ©2014 • positive? (https://goo.gl/UsTnWl ) • negative? class Integer # Returns true if the number is positive. # # 1.positive? # => true # 0.positive? # => false # -1.positive? # => false def positive? self > 0 end # Returns true if the number is negative. # # -1.positive? # => true # 0.positive? # => false # 1.positive? # => false def negative? self < 0 end end
  • 8. ©2014 • Inquiry ( https://goo.gl/47bjv7 , https://goo.gl/QpVmU3 ) class ArrayInquirer < Array def any?(*candidates, &block) if candidates.none? super else candidates.any? do |candidate| include?(candidate) || include?(candidate.to_sym) end end end private def respond_to_missing?(name, include_private = false) name[-1] == '?' end def method_missing(name, *args) if name[-1] == '?' any?(name[0..-2]) else super end end end
  • 10. ©2014 WE BUILD APPS THAT PEOPLE LOVE TO USE Enterprise Web Applications Development Cross-Platform Business Mobile Apps Development Social Media Integrated Applications Development Product Development Services