Class: RestKat::Resource
- Inherits:
-
Object
- Object
- RestKat::Resource
- Defined in:
- lib/rest_kat.rb
Instance Attribute Summary collapse
-
#hash ⇒ Object
Returns the value of attribute hash.
Instance Method Summary collapse
- #c_bool(r) ⇒ Object
- #c_permission_for(type) ⇒ Object
- #cached? ⇒ Boolean
- #collection_keypath ⇒ Object
- #create? ⇒ Boolean
- #delete? ⇒ Boolean
-
#initialize(resource) ⇒ Resource
constructor
A new instance of Resource.
- #item_keypath ⇒ Object
- #objc_class ⇒ Object
- #objc_resource_type ⇒ Object
- #permissions ⇒ Object
- #queries(&block) ⇒ Object
- #read? ⇒ Boolean
- #singleton? ⇒ Boolean
- #update? ⇒ Boolean
Constructor Details
#initialize(resource) ⇒ Resource
Returns a new instance of Resource.
4 5 6 |
# File 'lib/rest_kat.rb', line 4 def initialize resource self.hash = resource end |
Instance Attribute Details
#hash ⇒ Object
Returns the value of attribute hash.
3 4 5 |
# File 'lib/rest_kat.rb', line 3 def hash @hash end |
Instance Method Details
#c_bool(r) ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/rest_kat.rb', line 72 def c_bool r if r "true" else "false" end end |
#c_permission_for(type) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/rest_kat.rb', line 32 def type if .include? type "true" else "false" end end |
#cached? ⇒ Boolean
8 9 10 |
# File 'lib/rest_kat.rb', line 8 def cached? self.hash[:cached] end |
#collection_keypath ⇒ Object
24 25 26 |
# File 'lib/rest_kat.rb', line 24 def collection_keypath hash[:name] end |
#create? ⇒ Boolean
44 45 46 |
# File 'lib/rest_kat.rb', line 44 def create? @create ||= .include? 'c' end |
#delete? ⇒ Boolean
56 57 58 |
# File 'lib/rest_kat.rb', line 56 def delete? @delete ||= .include? 'd' end |
#item_keypath ⇒ Object
28 29 30 |
# File 'lib/rest_kat.rb', line 28 def item_keypath hash[:name].singularize end |
#objc_class ⇒ Object
16 17 18 |
# File 'lib/rest_kat.rb', line 16 def objc_class "MSRestResource#{hash[:name].camelize}" end |
#objc_resource_type ⇒ Object
12 13 14 |
# File 'lib/rest_kat.rb', line 12 def objc_resource_type hash[:type][:name] end |
#permissions ⇒ Object
20 21 22 |
# File 'lib/rest_kat.rb', line 20 def hash[:permissions] end |
#queries(&block) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/rest_kat.rb', line 60 def queries &block if hash.has_key?("queries") if block_given? hash["queries"].each &block else hash["queries"] end else [] end end |
#read? ⇒ Boolean
48 49 50 |
# File 'lib/rest_kat.rb', line 48 def read? @read ||= .include? 'r' end |
#singleton? ⇒ Boolean
40 41 42 |
# File 'lib/rest_kat.rb', line 40 def singleton? @singleton ||= .include? 's' end |
#update? ⇒ Boolean
52 53 54 |
# File 'lib/rest_kat.rb', line 52 def update? @update ||= .include? 'u' end |