Class: Store
- Inherits:
-
Object
- Object
- Store
- Defined in:
- app/models/store.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#tag ⇒ Object
Returns the value of attribute tag.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id, type, name, tag) ⇒ Store
constructor
A new instance of Store.
Constructor Details
#initialize(id, type, name, tag) ⇒ Store
Returns a new instance of Store.
5 6 7 8 9 10 |
# File 'app/models/store.rb', line 5 def initialize(id, type, name, tag) @id = id @type = type @name = name @tag = tag end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'app/models/store.rb', line 3 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'app/models/store.rb', line 3 def name @name end |
#tag ⇒ Object
Returns the value of attribute tag.
3 4 5 |
# File 'app/models/store.rb', line 3 def tag @tag end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'app/models/store.rb', line 3 def type @type end |
Class Method Details
.all(session_id:) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'app/models/store.rb', line 12 def self.all(session_id:) @all ||= begin stores_request = Mediaflux::StoreListRequest.new(session_token: session_id) data = stores_request.stores stores = data.map do |mf_store| Store.new(mf_store[:id], mf_store[:type], mf_store[:name], mf_store[:tag]) end stores end end |
.default(session_id:) ⇒ Object
27 28 29 |
# File 'app/models/store.rb', line 27 def self.default(session_id:) all(session_id: session_id).first end |
.get_by_name(name, session_id:) ⇒ Object
23 24 25 |
# File 'app/models/store.rb', line 23 def self.get_by_name(name, session_id:) all(session_id: session_id).find { |store| store.name == name } end |