Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base: e5590bc64b
...
compare: fccb6c33ed
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Showing with 23 additions and 11 deletions.
  1. +1 −1  TODO.md
  2. +3 −1 lib/kippt/list.rb
  3. +19 −9 lib/kippt/resource.rb
View
2  TODO.md
@@ -23,7 +23,7 @@
# List
* [DONE] Support for is private
-* Getting the user
+* [DONE] Getting the user
* Getting & setting the description
* Getting the collaborators of the list
* Getting the app url fo the clip
View
4 lib/kippt/list.rb
@@ -1,10 +1,12 @@
require "ostruct"
+require "kippt/user"
class Kippt::List
include Kippt::Resource
attributes :app_url, :id, :rss_url, :updated, :title,
- :created, :slug, :resource_uri
+ :created, :slug, :resource_uri,
+ :user => Kippt::User
boolean_attributes :is_private
writable_attributes :title
View
28 lib/kippt/resource.rb
@@ -16,21 +16,25 @@ module ClassMethods
def attributes(*attribs)
@attribute_names ||= []
hashes, other = attribs.partition {|attrib| attrib.is_a? Hash }
- hashes = hashes.reduce({}, :update)
- @attribute_names += other.map {|attrib| attrib.to_sym }
- def_delegators :attributes, *@attribute_names
- @attribute_names += hashes.keys.map {|attrib| attrib.to_sym }
- hashes.each do |attrib, object_class|
+
+ attribute_names = convert_to_symbols(other)
+ def_delegators :attributes, *attribute_names
+ @attribute_names += attribute_names
+
+ mappings = hashes.reduce({}, :update)
+ mappings.each do |attrib, object_class|
define_method(attrib) do
object_class.new(attributes.send(attrib))
end
end
+ @attribute_names += convert_to_symbols(mappings.keys)
end
def boolean_attributes(*attribs)
@attribute_names ||= []
- @attribute_names += attribs.map {|attrib| attrib.to_sym }
- def_delegators :attributes, *@attribute_names
+ attribute_names = convert_to_symbols(attribs)
+ def_delegators :attributes, *attribute_names
+ @attribute_names += attribute_names
attribs.each do |attribute_name|
if result = attribute_name.to_s.match(/\Ais\_(.*)/)
@@ -42,9 +46,15 @@ def boolean_attributes(*attribs)
end
def writable_attributes(*attribs)
- @writable_attribute_names = attribs.map {|attrib| attrib.to_sym }
+ @writable_attribute_names = convert_to_symbols(attribs)
@writable_attribute_names.freeze
- def_delegators :attributes, *(@writable_attribute_names.map {|attrib| attrib.to_s + "=" })
+ def_delegators :attributes, *(@writable_attribute_names.map {|attrib| attrib.to_s + "=" }).dup
+ end
+
+ private
+
+ def convert_to_symbols(list)
+ list.map {|item| item.to_sym }
end
end

No commit comments for this range

Something went wrong with that request. Please try again.