Module: ActiveGist::Attributes

Included in:
ActiveGist
Defined in:
lib/active_gist/attributes.rb

Constant Summary collapse

GIST_ATTRIBUTES =
%w(url id description public user files comments
html_url git_pull_url git_push_url created_at
forks forks_url history updated_at comments_url commits_url)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#commentsObject (readonly)

Returns the value of attribute comments.



10
11
12
# File 'lib/active_gist/attributes.rb', line 10

def comments
  @comments
end

#comments_urlObject (readonly)

Returns the value of attribute comments_url.



10
11
12
# File 'lib/active_gist/attributes.rb', line 10

def comments_url
  @comments_url
end

#commits_urlObject (readonly)

Returns the value of attribute commits_url.



10
11
12
# File 'lib/active_gist/attributes.rb', line 10

def commits_url
  @commits_url
end

#created_atObject (readonly)

Returns the value of attribute created_at.



10
11
12
# File 'lib/active_gist/attributes.rb', line 10

def created_at
  @created_at
end

#descriptionObject

Returns the value of attribute description.



10
11
12
# File 'lib/active_gist/attributes.rb', line 10

def description
  @description
end

#filesObject

Returns the value of attribute files.



10
11
12
# File 'lib/active_gist/attributes.rb', line 10

def files
  @files
end

#forksObject (readonly)

Returns the value of attribute forks.



10
11
12
# File 'lib/active_gist/attributes.rb', line 10

def forks
  @forks
end

#forks_urlObject (readonly)

Returns the value of attribute forks_url.



10
11
12
# File 'lib/active_gist/attributes.rb', line 10

def forks_url
  @forks_url
end

#git_pull_urlObject (readonly)

Returns the value of attribute git_pull_url.



10
11
12
# File 'lib/active_gist/attributes.rb', line 10

def git_pull_url
  @git_pull_url
end

#git_push_urlObject (readonly)

Returns the value of attribute git_push_url.



10
11
12
# File 'lib/active_gist/attributes.rb', line 10

def git_push_url
  @git_push_url
end

#historyObject (readonly)

Returns the value of attribute history.



10
11
12
# File 'lib/active_gist/attributes.rb', line 10

def history
  @history
end

#html_urlObject (readonly)

Returns the value of attribute html_url.



10
11
12
# File 'lib/active_gist/attributes.rb', line 10

def html_url
  @html_url
end

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/active_gist/attributes.rb', line 10

def id
  @id
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



10
11
12
# File 'lib/active_gist/attributes.rb', line 10

def updated_at
  @updated_at
end

#urlObject (readonly)

Returns the value of attribute url.



10
11
12
# File 'lib/active_gist/attributes.rb', line 10

def url
  @url
end

#userObject (readonly)

Returns the value of attribute user.



10
11
12
# File 'lib/active_gist/attributes.rb', line 10

def user
  @user
end

Class Method Details

.included(base) ⇒ Object

:nodoc:



6
7
8
# File 'lib/active_gist/attributes.rb', line 6

def self.included(base) #:nodoc:
  base.define_attribute_methods GIST_ATTRIBUTES
end

Instance Method Details

#[](attribute) ⇒ Object



65
66
67
# File 'lib/active_gist/attributes.rb', line 65

def [](attribute)
  send attribute.to_sym
end

#[]=(attribute, value) ⇒ Object



69
70
71
# File 'lib/active_gist/attributes.rb', line 69

def []=(attribute, value)
  send :"#{attribute}=", value
end

#attributesObject



47
48
49
# File 'lib/active_gist/attributes.rb', line 47

def attributes
  GIST_ATTRIBUTES.inject({}) { |h,k| h[k] = self[k]; h }
end

#attributes=(attributes) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/active_gist/attributes.rb', line 51

def attributes=(attributes)
  attributes.each do |key, value|
    if respond_to?(:"#{key}=")
      send :"#{key}=", value
    else
      if GIST_ATTRIBUTES.include?(key.to_s)
        instance_variable_set :"@#{key}", value
      else
        raise ArgumentError, "Unknown attribute #{key.inspect}; expected one of #{GIST_ATTRIBUTES.inspect}"
      end
    end
  end
end

#public=(pub) ⇒ Object



37
38
39
40
# File 'lib/active_gist/attributes.rb', line 37

def public=(pub)
  public_will_change!
  @public = pub
end

#public?Boolean Also known as: public

Returns:

  • (Boolean)


27
28
29
# File 'lib/active_gist/attributes.rb', line 27

def public?
  !!@public
end