Class: Idiomag::User
- Inherits:
-
Object
- Object
- Idiomag::User
- Defined in:
- lib/idiomag/user.rb
Instance Attribute Summary collapse
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #get(*args) ⇒ Object
-
#initialize(user) ⇒ User
constructor
A new instance of User.
- #method_missing(method, *args) ⇒ Object
- #respond_to?(method) ⇒ Boolean
Constructor Details
#initialize(user) ⇒ User
Returns a new instance of User.
5 6 7 8 |
# File 'lib/idiomag/user.rb', line 5 def initialize(user) raise ArgumentError if user.blank? @user = user end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/idiomag/user.rb', line 40 def method_missing(method, *args) case method when :name get_info if @name.nil? @name when :email get_info if @email.nil? @email when :url get_info if @url.nil? @url when :artists get_info if @artists.nil? @artists when :tags get_info if @tags.nil? @tags when :articles get_articles if @articles.nil? @articles when :loved_articles get_loved_articles if @loved_articles.nil? @loved_articles when :photos get_photos if @photos.nil? @photos when :videos get_videos if @videos.nil? @videos when :playlist, :tracks get_playlist if @playlist.nil? @playlist else super end end |
Instance Attribute Details
#user ⇒ Object
Returns the value of attribute user.
3 4 5 |
# File 'lib/idiomag/user.rb', line 3 def user @user end |
Instance Method Details
#get(*args) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/idiomag/user.rb', line 10 def get(*args) args.each do |action| case action when :info get_info when :articles get_articles when :loved_articles get_loved_articles when :photos get_photos when :videos get_videos when :playlist, :tracks get_playlist else raise ArgumentError end end end |
#respond_to?(method) ⇒ Boolean
31 32 33 34 35 36 37 38 |
# File 'lib/idiomag/user.rb', line 31 def respond_to?(method) case method when :name,:email,:url,:tags,:artists,:articles,:loved_articles,:photos,:videos,:playlist,:tracks true else super end end |