Class: FmRest::Spyke::ContainerField
- Inherits:
-
Object
- Object
- FmRest::Spyke::ContainerField
- Defined in:
- lib/fmrest/spyke/container_field.rb
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
The name of the container field.
Instance Method Summary collapse
- #download ⇒ Object
-
#initialize(base, name) ⇒ ContainerField
constructor
A new instance of ContainerField.
- #upload(filename_or_io, options = {}) ⇒ Object
-
#url ⇒ String
The URL for the container.
Constructor Details
#initialize(base, name) ⇒ ContainerField
Returns a new instance of ContainerField.
12 13 14 15 |
# File 'lib/fmrest/spyke/container_field.rb', line 12 def initialize(base, name) @base = base @name = name end |
Instance Attribute Details
#name ⇒ String (readonly)
Returns the name of the container field.
8 9 10 |
# File 'lib/fmrest/spyke/container_field.rb', line 8 def name @name end |
Instance Method Details
#download ⇒ Object
23 24 25 |
# File 'lib/fmrest/spyke/container_field.rb', line 23 def download FmRest::V1.fetch_container_data(url, @base.class.connection) end |
#upload(filename_or_io, options = {}) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/fmrest/spyke/container_field.rb', line 33 def upload(filename_or_io, = {}) raise ArgumentError, "Record needs to be saved before uploading to a container field" unless @base.persisted? response = FmRest::V1.upload_container_data( @base.class.connection, upload_path([:repetition] || 1), filename_or_io, ) # Update mod id on record @base.__mod_id = response.body[:data][:__mod_id] true end |
#url ⇒ String
Returns the URL for the container.
18 19 20 |
# File 'lib/fmrest/spyke/container_field.rb', line 18 def url @base.attributes[name] end |