Class: HAL::S3::DirectoryIndex
- Inherits:
-
Object
- Object
- HAL::S3::DirectoryIndex
- Defined in:
- lib/hal/s3.rb
Instance Attribute Summary collapse
-
#relation_name ⇒ Object
readonly
Returns the value of attribute relation_name.
-
#self_url ⇒ Object
readonly
Returns the value of attribute self_url.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(uri, relation_name: 'items', self_url: nil) ⇒ DirectoryIndex
constructor
A new instance of DirectoryIndex.
- #to_hash ⇒ Object
- #to_json(pretty: false) ⇒ Object
Constructor Details
#initialize(uri, relation_name: 'items', self_url: nil) ⇒ DirectoryIndex
Returns a new instance of DirectoryIndex.
10 11 12 13 14 15 16 17 18 |
# File 'lib/hal/s3.rb', line 10 def initialize(uri, relation_name: 'items', self_url: nil) @uri = URI(uri) @relation_name = relation_name @self_url = self_url = {} [:endpoint] = "https://s3-#{ENV['AWS_REGION']}.amazonaws.com" if ENV['AWS_REGION'] @s3 = Aws::S3::Client.new() end |
Instance Attribute Details
#relation_name ⇒ Object (readonly)
Returns the value of attribute relation_name.
8 9 10 |
# File 'lib/hal/s3.rb', line 8 def relation_name @relation_name end |
#self_url ⇒ Object (readonly)
Returns the value of attribute self_url.
8 9 10 |
# File 'lib/hal/s3.rb', line 8 def self_url @self_url end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
8 9 10 |
# File 'lib/hal/s3.rb', line 8 def uri @uri end |
Instance Method Details
#to_hash ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/hal/s3.rb', line 20 def to_hash data = { '_links' => {'self' => {'href' => self_url}} } data['_links'][relation_name] = hrefs data end |
#to_json(pretty: false) ⇒ Object
28 29 30 |
# File 'lib/hal/s3.rb', line 28 def to_json(pretty: false) pretty ? JSON.pretty_unparse(to_hash) : to_hash.to_json end |