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
-
#comments ⇒ Object
readonly
Returns the value of attribute comments.
-
#comments_url ⇒ Object
readonly
Returns the value of attribute comments_url.
-
#commits_url ⇒ Object
readonly
Returns the value of attribute commits_url.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#description ⇒ Object
Returns the value of attribute description.
-
#files ⇒ Object
Returns the value of attribute files.
-
#forks ⇒ Object
readonly
Returns the value of attribute forks.
-
#forks_url ⇒ Object
readonly
Returns the value of attribute forks_url.
-
#git_pull_url ⇒ Object
readonly
Returns the value of attribute git_pull_url.
-
#git_push_url ⇒ Object
readonly
Returns the value of attribute git_push_url.
-
#history ⇒ Object
readonly
Returns the value of attribute history.
-
#html_url ⇒ Object
readonly
Returns the value of attribute html_url.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
-
.included(base) ⇒ Object
:nodoc:.
Instance Method Summary collapse
- #[](attribute) ⇒ Object
- #[]=(attribute, value) ⇒ Object
- #attributes ⇒ Object
- #attributes=(attributes) ⇒ Object
- #public=(pub) ⇒ Object
- #public? ⇒ Boolean (also: #public)
Instance Attribute Details
#comments ⇒ Object (readonly)
Returns the value of attribute comments.
10 11 12 |
# File 'lib/active_gist/attributes.rb', line 10 def comments @comments end |
#comments_url ⇒ Object (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_url ⇒ Object (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_at ⇒ Object (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 |
#description ⇒ Object
Returns the value of attribute description.
10 11 12 |
# File 'lib/active_gist/attributes.rb', line 10 def description @description end |
#files ⇒ Object
Returns the value of attribute files.
10 11 12 |
# File 'lib/active_gist/attributes.rb', line 10 def files @files end |
#forks ⇒ Object (readonly)
Returns the value of attribute forks.
10 11 12 |
# File 'lib/active_gist/attributes.rb', line 10 def forks @forks end |
#forks_url ⇒ Object (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_url ⇒ Object (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_url ⇒ Object (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 |
#history ⇒ Object (readonly)
Returns the value of attribute history.
10 11 12 |
# File 'lib/active_gist/attributes.rb', line 10 def history @history end |
#html_url ⇒ Object (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 |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/active_gist/attributes.rb', line 10 def id @id end |
#updated_at ⇒ Object (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 |
#url ⇒ Object (readonly)
Returns the value of attribute url.
10 11 12 |
# File 'lib/active_gist/attributes.rb', line 10 def url @url end |
#user ⇒ Object (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 |
#attributes ⇒ Object
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
27 28 29 |
# File 'lib/active_gist/attributes.rb', line 27 def public? !!@public end |