Class: DotMailer::DataField
- Inherits:
-
Object
- Object
- DotMailer::DataField
- Defined in:
- lib/dot_mailer/data_field.rb
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #date? ⇒ Boolean
- #default ⇒ Object
-
#initialize(attributes) ⇒ DataField
constructor
A new instance of DataField.
- #name ⇒ Object
- #to_json(options = {}) ⇒ Object
- #to_s ⇒ Object
- #type ⇒ Object
- #visibility ⇒ Object
Constructor Details
#initialize(attributes) ⇒ DataField
Returns a new instance of DataField.
22 23 24 |
# File 'lib/dot_mailer/data_field.rb', line 22 def initialize(attributes) self.attributes = attributes end |
Class Method Details
.all(account) ⇒ Object
3 4 5 6 7 |
# File 'lib/dot_mailer/data_field.rb', line 3 def self.all(account) fields = account.client.get '/data-fields' fields.map { |attributes| new(attributes) } end |
.create(account, name, options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/dot_mailer/data_field.rb', line 9 def self.create(account, name, = {}) [:type] ||= 'String' [:visibility] ||= 'Public' account.client.post_json( '/data-fields', 'name' => name, 'type' => [:type], 'visibility' => [:visibility], 'defaultValue' => [:default] ) end |
Instance Method Details
#==(other) ⇒ Object
50 51 52 |
# File 'lib/dot_mailer/data_field.rb', line 50 def ==(other) attributes == other.attributes end |
#date? ⇒ Boolean
54 55 56 |
# File 'lib/dot_mailer/data_field.rb', line 54 def date? type == 'Date' end |
#default ⇒ Object
38 39 40 |
# File 'lib/dot_mailer/data_field.rb', line 38 def default attributes['defaultValue'] end |
#name ⇒ Object
26 27 28 |
# File 'lib/dot_mailer/data_field.rb', line 26 def name attributes['name'] end |
#to_json(options = {}) ⇒ Object
42 43 44 |
# File 'lib/dot_mailer/data_field.rb', line 42 def to_json( = {}) attributes.to_json end |
#to_s ⇒ Object
46 47 48 |
# File 'lib/dot_mailer/data_field.rb', line 46 def to_s %{#{self.class.name} name: "#{name}", type: "#{type}", visibility: "#{visibility}", default: "#{default}"} end |
#type ⇒ Object
30 31 32 |
# File 'lib/dot_mailer/data_field.rb', line 30 def type attributes['type'] end |
#visibility ⇒ Object
34 35 36 |
# File 'lib/dot_mailer/data_field.rb', line 34 def visibility attributes['visibility'] end |